【问题标题】:URL cleanup in PHPPHP 中的 URL 清理
【发布时间】:2015-08-13 03:12:44
【问题描述】:

我想做这样的事情:

domain.com/movie.php?mno=abc

我不希望用户看到这个。
而不是这个,我想显示:

domain.com/movie/abc

我在 php 工作,有谁能帮帮我吗?
我使用了.htaccess 并在其中尝试了许多不同的代码,但没有得到我想要的输出。

AddType text/x-component .htc
RewriteEngine On
RewriteBase /
 # remove .php; use THE_REQUEST to prevent infinite loops
 RewriteCond %{THE_REQUEST} ^GET\ (.*)\.php\ HTTP
 RewriteRule (.*)\.php$ $1 [R=301]
 # remove index
 RewriteRule (.*)/index$ $1/ [R=301]
 # remove slash if not directory
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteCond %{REQUEST_URI} /$
 RewriteRule (.*)/ $1 [R=301]
 # add .php to access file, but don't redirect
 RewriteCond %{REQUEST_FILENAME}.php -f
 RewriteCond %{REQUEST_URI} !/$
 RewriteRule (.*) $1\.php [L] 
 RewriteRule ^movie/(\d+)*$ ./moviedownload.php?mno=$1 [NC,L]

【问题讨论】:

标签: php


【解决方案1】:

你在那个文件中有很多事情要做。如果它们作用于不同的事物,则应使用某些条件。

至于你问的问题,试试这个:

RewriteEngine On

RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f

RewriteRule ^movie/(\d+)*$ ./movie.php?mno=$1

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-05-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多