Reputation: 760
I'm trying to get htaccess to rewrite this url :
http://127.0.0.1/papercut3/article/post-title/
to this:
http://127.0.0.1/papercut3/article.php?p=post-title/
My current .htaccess is:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^article/(\d+)*$ ./article.php?p=$1
RewriteRule ^section/(\d+)*$ ./section.php?s=$1
And my urls written in the code:
http://127.0.0.1/papercut3/article/execution-call-for-cinema-killer/
My problem is that when I click the link I get this:
Not Found
The requested URL /papercut3/article/syria-suffers-deadliest-month/ was not found on this server.
I'm using WAMP, the .htaccess is in the root of the /papercut3 directory with all the core files. Any help would be greatly appreciated!:)
Upvotes: 0
Views: 64
Reputation: 4736
If you can use .htaccess
files, you want it to look like:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^article/(.+)$ ./article.php?p=$1
RewriteRule ^section/(.+)$ ./section.php?s=$1
Or, you can be slightly more specific with what is allowed, but the one in your question only allows character [0-9]
, this way it opens it up and let's the respective PHP files do the checking/error-handling.
Upvotes: 1
Reputation: 11220
You may find help in the log file of apache, but I think this is related to AllowOverride
directive, which must be set to None.
As said in the documentation, you need AllowOverride
to contain at least FileInfo
.
Edit: By the way, your rule won't match any of your url since you expect a int \d
but don't provide any in input.
Upvotes: 0