.htaccess : what is wrong with this rule?
may you please tell me where is my fault ?
RewriteRule ^project/([^.]+)/$ /wordpress/wp-content/pl开发者_运维技巧ugins/pr/cp.php?id=$1 [QSA,L]
i get Internal Server Error everytime i apply it
Thank you
EDIT
127.0.0.1/wordpress/project/43928fdsf
redirects to
127.0.0.1/wordpress/wp-content/plugins/pr/cp.php?id=43928fdsf
Your expression is fine which would suggest mod_rewrite
is not installed/working/turned on. Change your code to look like this:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^project/([^.]+)/$ /wordpress/wp-content/plugins/pr/cp.php?id=$1 [QSA,L]
</IfModule>
That should stop there being any 500 errors (if they were indeed mod_rewrite
related). If your URL rewrites still don't work then you don't have mod_rewrite
installed/enabled, in which case you can install and enable it.
UPDATE
You have a forward slash at the end o your RewriteRule but you want to match a URL like 127.0.0.1/wordpress/project/43928fdsf, which has no forward slash at the end. Just remove the forward slash and the rule should match:
RewriteRule ^project/([^.]+)$ /wordpress/wp-content/plugins/pr/cp.php?id=$1 [QSA,L]
From then on if you're still getting a 500 error then try printing the $_GET
variables at the top of your PHP file, then call exit()
and see if you still have the problem. This should help to narrow down whether the problem is with PHP or Apache.
If you're trying to match a single URL part with that group then you are doing it wrong because [^.]+
will also match /
. E.g.: project/a/b/c/
will also match => $1
will be a/b/c
On another note, have you checked what groups you're capturing? And if those values that you then send through parameter id
are not causing cp.php
to crash?
精彩评论