Giang Nguyen
Giang Nguyen

Reputation: 485

Mod_Rewrite with .htaccess is not working

I just learnt about url-rewrite for my website with .htacess. My actual url is:

localhost/index.php?view=some-page

So i write this RewriteRule like this:

RewriteRule  ^/([^/]*)/?$   /index.php?view=$1 [NC,L]

When i typed localhost/homepage on my browser, It does not work, it displays error 404 object not found. What have i done wrong please show me.

Many thanks

Upvotes: 1

Views: 29

Answers (2)

anubhava
anubhava

Reputation: 785876

This should work in your DocumentRoot/.htaccess:

RewriteEngine On
RewriteBase /

RewriteRule  ^([^/]+)/?$ index.php?view=$1 [QSA,L]

Leading slash is not matched in htaccess.

Upvotes: 1

Chaves MainMan
Chaves MainMan

Reputation: 29

are you using apache?

This link from step 6 helped me

https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-on-ubuntu-14-04

When i was playing around with rewrites i had to enable it and tell apache where the pages were stored

Upvotes: 0

Related Questions