qadenza
qadenza

Reputation: 9293

RewriteRule on localhost

localhost, xampp, win 7
site root folder is s02, so all relevant files, including .htaccess is under this folder.

links like this work fine:
http://localhost/news/s02/view.php?art=160915142500&title=blue-sky

I want the following computed url
http://localhost/articles/160915142500/blue-sky

.htaccess

RewriteEngine on
RewriteBase /
RewriteRule ^articles/([0-9]+)/([a-zA-Z-_]*)$ view.php?art=$1&title=$2 [NC,L]

result - error 404

httpd.conf
LoadModule rewrite_module modules/mod_rewrite.so - uncommented
AllowOverride All

.htaccess (test) - this works:

RewriteEngine on
RewriteRule ^ http://example.com/? [L,R]  

phpinfo();
mod_rewrite is under Loaded Modules

Any help?

Upvotes: 0

Views: 3772

Answers (2)

Abhishek Gurjar
Abhishek Gurjar

Reputation: 7476

Try with below rule, we are telling apache that incoming uri is not a file or directory.

RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^articles/([0-9]+)/([a-zA-Z-_]*)$ /news/s02/view.php?art=$1&title=$2 [NC,L]

Upvotes: 1

lkdhruw
lkdhruw

Reputation: 582

Place .htaccess file into the root folder i.e. htdocs for xampp (I guess). The .htaccess file should be like this.

RewriteEngine on
RewriteBase /
RewriteRule ^articles/([0-9]+)/([a-zA-Z-_]*)$ news/s02/view.php?art=$1&title=$2 [NC,L]

Upvotes: 0

Related Questions