`example.com/recent/index.php?page=2` i want to like this -> `example.com/recent/page/2`
.htaccess
Options +FollowSymLinks
RewriteEngine On
RewriteBase /recent/
RewriteRule ^([^/]+/([0-9]+)/?$ index.php?page=$2 [L,QSA]
index.php?page=2
<?php
echo $_GET['page'];
?>
如何为该htaccess文件创建
我的网站上有一个动态显示内容的页面。URL结构是mywebsite.com/giveaway/giveaway.php?id=(any number),我希望将该动态URL更改为静态/友好的URL mywebsite.com/giveaway/name-of-giveaway-corresponding-to-id。在根文件夹中找到的.htaccess文件中,我有以下内容:
RewriteEngine On
# external redirect from actual URL to pretty one
RewriteCond %{THE_REQUEST} \s/+
我正在使用example.php将大约100个hmtl页面重定向到单个PHP页面( .htaccess )。它运转得很好。
我已经在那个页面上分页了(example.php),但是我使用的是原始的HTML (example.html?page=2&limit=20)
so example.html、example1.html、example2.html、example3.html都重定向到example.php。地址栏仍在显示“rendering.when”URL,但由于.htaccess重定向,example.php is .htaccess是单击分页链接(example.html?
我有一个友好的URL,如下所示:
www.dominio.com.br/cidade/sao-paulo
下面是我的htaccess重写规则:
RewriteRule ^cidade/(.*)$ busca-cidade.php?cidade=$1
和SQL查询:
Select * from cidades where cidade = 'sao-paulo'
是否可以使用htaccess和重写规则将连字符替换为空格?因此,友好的URL将被映射到:
www.dominio.com.br/busca-cidade.php?cidade=sao%20paulo
这就完成了我的代码,