How to use mod rewrite

I have migrated my website from the old server to a shared server.

All my code is in "lfdata/main/com"

under "public_html"

a shared server.

The clean url will look like this:

http: // ip-address / ~ name / how

and the rewritten url should be:

http: //ip-address/~name/lfdata/main/com/how.php

So can anyone suggest a rewrite rule to generate the above url?

0


a source to share


2 answers


Try the following rule:

RewriteCond %{REQUEST_URI} !^/~[^/]+/lfdata/main/com/
RewriteRule ^(~[^/]+)/(.+) $1/lfdata/main/com/$2.php [L]

      



This will rewrite any request /~

name

/

foobar

internally before /~

name

/lfdata/main/com/

foobar

.php

.

+2


a source


this will do your rewrite including query string parameters



RewriteRule ^~name/how(.*)$ ~name/lfdata/main/com/how.php$1

      

0


a source







All Articles