简体   繁体   中英

htaccess rewriteRule Fix

I have little problem on the here

http//site.com/detial.php?verifyID=$parametre

i want this like short url :

http://site.com/$parametre

how can we do? thanks

Options +FollowSymLinks
RewriteEngine on

RewriteRule ^([^/]*)\$ /detial.php?parametre=$1 [L]
# Error Pages
ErrorDocument 404 /404.php
<Files 403.shtml>
order allow,deny
allow from all
</Files>

i am using this but giving 404 error how can we fix

Try the following code.

RewriteEngine On
RewriteRule ^([a-zA-Z0-9_-]+)$ detial.php?parametre=$1
RewriteRule ^([a-zA-Z0-9_-]+)/$ detial.php?parametre=$1

Assumed the PHP

header("content-type: text/plain");
if (isset($_GET['q']))
  echo $_GET['q'];
else
  echo "empty";

You can get the URL in $_GET['q'] by the following

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ index.php?q=$1 [QSA,L]
</IfModule>

Note that it will also check that the requested resource is not an existing file !-f or directory !-d in the filesystem

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM