使用 htaccess 重写 PHP url

2024-01-02

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

to

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

使用 htaccess。

目前使用

<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需要那个

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

使用 htaccess 重写 PHP url 的相关文章

随机推荐