i was confused about trailing slash, this is script i got from internet
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !index.php
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ http://domain.com/$1/ [L,R=301]
Options All -indexes
My question:
1.what function of %{REQUEST_FILENAME} !-f
2.what function of RewriteCond %{REQUEST_URI} !index.php
3.what function of RewriteCond %{REQUEST_URI} !(.*)/$
4.how can i write Rewrite url if the original url like:
def.php?p=cpanel&m=add_user
,
i want the link above rewrite like cpanel/add_user
thanks
The rule need is this:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^cpanel/([^/]+)/?$ def.php?p=cpanel&m=$1 [L,QSA,NC]
RewriteCond %{REQUEST_FILENAME} !-f
means iif request is not for a valid file $1
is backreference to captured string after /cpanel/
QSA
(Query String Append) flag preserves existing query parameters while adding a new one. NC
is for ignore case L
is for Last rule 1.what function of %{REQUEST_FILENAME} !-f
2.what function of RewriteCond %{REQUEST_URI} !index.php
3.what function of RewriteCond %{REQUEST_URI} !(.*)/$
You should read the rewrite guide http://httpd.apache.org/docs/2.0/misc/rewriteguide.html
how can i write Rewrite url if the original url like:
def.php?p=cpanel&m=add_user ,
i want the link above rewrite like cpanel/add_user
You can use this code in you .htaccess file
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^cpanel/(.*)$ def.php?p=cpanel&m=$1 [L,QSA,NC]
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.