Apache rewrite url
I am trying to rewrite url and it fails. May I know what is wrong? Would someone please enlighten me? I placed the code in .htaccess. I have enabled rewrite_module too.
RewriteEngine On
RewriteRule /place/^([a-zA-Z0-9])$ /placelink.php?lid=$1
For example: domain.com/place/xyz -> domain.com/placelink.php?id=xyz
Update:
I have just found out that my syntax is now correct. But it is not mod_rewrite that is not working. phpinfo shows mod_rewrite module is available.
Update 2
RewriteEngine On
开发者_运维知识库RewriteRule ^/?test\.html$ test.php [L]
Chances are you want this...
RewriteEngine On
RewriteRule ^place/([a-zA-Z0-9-]+)/?$ /placelink.php?lid=$1
This will take requests for..
domain.com/place/the-moon
...and will serve up...
domain.com/placelink.php?lid=the-moon
^
means 'the start of the string. /path/
is a literal. So you're asking for a string which has /path/
in it, after which the string starts. This is logically impossible. See http://regularexpressions.info for more information about regexes.
精彩评论