How to write htaccess file, change url
I am trying to convert the actual url to user friendly dynamic menu, when the user clicks on the orignal url page it becomes
http://example.com/single.php?name=mypagename
I want to change it to
http://example.com/page/mypagename
here is my htaccess file i tried from different angles. Please can someone help fix it.
# For security reasons, Option followsymlinks cannot be overridden.
#Options +FollowSymlinks -Multiviews
Options +SymLinksIfOwnerMatch -Multiviews
RewriteEngine on
RewriteBase /
RewriteCond %{THE_REQUEST} ^(GET|HEAD|POST)\ /single\.php(\?|\ )
RewriteCond %{QUERY_STRING} name=(.+)
RewriteRule page/(.*) single.php?name=$1
RewriteRule ^ /page/%1? [L,R=301]
+3
source to share
3 answers
You must change your directives:
# For security reasons, Option followsymlinks cannot be overridden.
#Options +FollowSymlinks -Multiviews
Options +SymLinksIfOwnerMatch -Multiviews
RewriteEngine on
RewriteBase /
RewriteCond %{THE_REQUEST} \s/+single\.php\?name=([^\s&]+) [NC]
RewriteRule ^ /page/%1? [L,R=301]
RewriteRule ^page/(.*)$ single.php?name=$1 [L,NC,QSA]
RewriteCond %{THE_REQUEST} \s/+(Web/2015/wessexcars)/internalpage\.php?seo=\?name=([^\s&]+) [NC]
RewriteRule ^ %1/%2? [L,R=301]
RewriteRule ^(Web/2015/wessexcars)/(.+?)/?$ $1/internalpage.php?seo=$1 [L,NC,QSA]
+1
source to share
first change your config file making the index file empty
$config['index_page'] = '';
and create htaccess file
<ifmodule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</ifmodule>
0
source to share