skip to Main Content

I am having some trouble rewriting and redirecting my URLs. This is what I am trying to do:

Currently I have this URL: domain.com/server.php?id=$1

I have that URL above which rewrites to: domain.com/details/$1

The problem I am having is when you go to: domain.com/server.php?id=$1 it doesn’t redirect to my SEO friendly URL.

Does anyone know why?

This is my current rewrite for the url:
RewriteRule ^details/(.*)/ server?id=$1 [L]

2

Answers


  1. Chosen as BEST ANSWER

    This is my what I found to work for me: # external redirect from actual URL to pretty one RewriteCond %{THE_REQUEST} s/+server.php?id=([^s&]+) [NC] RewriteRule ^ details/%1? [R=301,L,NE]

    # internal forward from pretty URL to actual one RewriteRule ^details/([^/.]+)/?$ server.php?id=$1 [L,QSA,NC]


  2. Use this:

    RewriteEngine On
    RewriteRule ^details/([^/]*)$ /server.php?id=$1 [L]
    

    It will give you the URL: domain.com/details/$1. Just make sure you clear your cache before testing it.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search