Reputation: 1511
I use this htaccess url mywebsite.com/xyz/search.html
here xyz is a folder in root
in .htaccess is use the code for this url
# enable apache modRewrite module #
RewriteEngine On
RewriteBase /
RewriteRule ^([^//]+)/?(^/*)?.ht(m?ml?)$ index.php?page=$1 [L,QSA]
now i want this
xyz/search.html
is hit the
url xyz/index.php?page=search
but this:
RewriteRule ^([^//]+)/?(^/*)?.ht(m?ml?)$ index.php?page=$1 [L,QSA])
code is not working.. any idea regarding this...
Upvotes: 0
Views: 17457
Reputation: 2279
There is a very handy online tool for testing htaccess files. Simply paste your redicrect rules in the form provided and test various urls to see if they are redirected or left untouched.... soooper easy!
Upvotes: 1
Reputation: 129
Type some random characters in your .htaccess file and try to reload your page, if you see error 500 then your .htaccess file is working, put your random characters after "RewriteEngine On" .
Upvotes: 12
Reputation: 143886
Try:
RewriteEngine On
RewriteBase /
RewriteRule ^(.*?)/?([^/]+)\.ht(m|ml)?$ $1/index.php?page=$2 [L,QSA]
Upvotes: 1
Reputation: 32290
I wonder why people don't use RewriteLog
.
Put in the same place:
RewriteLog /tmp/rewrite.log
RewriteLogLevel 3
It slows down the server but for debugging it's made for.
Upvotes: 1
Reputation: 22831
Not sure that rule would work. Does this one do the job?
RewriteRule ^.*/(.*)\.html?$ index.php?page=$1 [L,QSA]
Also, if you want to test the rule with a bit more visibility, you can add R=302
to the flags, that way your browser will get a redirect and you'll be able to see the rewritten URL in the address bar
Upvotes: 2