I am trying to rewrite one of my urls to pretty urls but I can't seem to figure it out. Here is what I've tried
Current folder layout
-index.php
-/instagram
-index.php
-.htaccess
Inside the .htaccess I have put this code
RewriteEngine On
RewriteRule ^instagram/([^/]*)$ /instagram/?username=$1 [L]
My goal is to turn this url
http://example.com/instagram/?username=test1234
into this url
http://example.com/instagram/test1234
However, when I go to the second url in my browser it gives a 404 not found error. Any idea on how to fix this?
Place this code inside /instagram/.htaccess
:
DirectoryIndex index.php
RewriteEngine On
RewriteBase /instagram/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/?$ index.php?username=$1 [L,QSA]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.