且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用PHP htaccess的URL重写

更新时间:2022-12-27 18:12:15

 如果($ _ SERVER ['REQUEST_URI'] =='/ justridesbeta / jstride /车辆)
{
    标题(位置:http://www.example.com/justridesbeta/addride);
    出口;
}
 

如果你的真正的需要了。

http://www.example.com/justridesbeta/jstride/vehicle

to

http://www.example.com/justridesbeta/addride

using htaccess.

Currently using

<IfModule mod_rewrite.c>
  Options +FollowSymLinks
  RewriteEngine On

  # Get rid of index.php
  RewriteCond %{REQUEST_URI} /index\.php
  RewriteRule (.*) index.php?rewrite=2 [L,QSA]

  # Rewrite all directory-looking urls
  RewriteCond %{REQUEST_URI} /$
  RewriteRule (.*) index.php?rewrite=1 [L,QSA]

  # Try to route missing files
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} public\/ [OR]
  RewriteCond %{REQUEST_FILENAME} \.(jpg|gif|png|ico|flv|htm|html|php|css|js)$
  RewriteRule . - [L]

  # If the file doesn't exist, rewrite to index
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ index.php?rewrite=1 [L,QSA]



  RewriteRule ^[a-zA-Z0-9]+$ justridesbeta/jstride/vehicle
  </IfModule>

if ($_SERVER['REQUEST_URI'] == '/justridesbeta/jstride/vehicle')
{
    header("Location: http://www.example.com/justridesbeta/addride");
    exit;
}

if you really need that