php - Mod-rewrite.htaccess not working
Hi I previously posted a question on to Stack Over flow and was lucky enough to receive some assistance to my initial question which helped me better understand that what i was trying to achieve was possible.
The previous question is here: Visit php url shortening
I am building a system where users can share their profile on other websites so i am wondering is it possible to shorten the actual url which would provide a link to their profile which would be something like this, www.somedomain.com/users/profile.php?user=myusername to simply cut out the users folder and the profile page and so something like this: www.somedomain.com/myusername
the code I have is:
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule /(.*) /users/profile.php?user=$1
Sadly two things happen, firstly the code doesn't work and secondly when i add this code the css on the original long domain stops working.
Any suggestions would be appreciated
Answer
Solution:
code doesn't work
: of course it won't because it's incorrect. Really wondering how did you end up accepting other question without properly testing it. Anyway take this code and replace your existing .htaccess code:Answer
Solution:
This is serverfault question.
Are apache mod_rewrite module enabled?
debian: a2enmod rewrite; /etc/init.d/apache2 restart
Are enabled override for this directory? In case using default vhost:
What are showing error.log? tail /var/log/apache2/error.log
Try simple version:
Code: