Php 要通过修改htaccess在url末尾隐藏page.html吗

Php 要通过修改htaccess在url末尾隐藏page.html吗,php,.htaccess,mod-rewrite,Php,.htaccess,Mod Rewrite,有人能帮我重定向htaccess中的url吗。正如下面的链接所示,我不想在最后显示它的showing page.html,是否可以通过更改htaccess中的任何内容,也可以在许多URL中显示很多内容,我还想更改为/或任何其他字符以使其看起来合适 http://www.domain.com/98-three-wheelers/listings.html http://www.domain.com/63-we-are-currently-looking-for-customer-care-exec

有人能帮我重定向htaccess中的url吗。正如下面的链接所示,我不想在最后显示它的showing page.html,是否可以通过更改htaccess中的任何内容,也可以在许多URL中显示很多内容,我还想更改为/或任何其他字符以使其看起来合适

http://www.domain.com/98-three-wheelers/listings.html
http://www.domain.com/63-we-are-currently-looking-for-customer-care-executive-for-a-call-center-in-ahmedabad/details.html
我使用的htaccess如下所示:

RewriteRule ^index.html index.php [nc]
RewriteRule ^recent_ads.html recent_ads.php [nc]
RewriteRule ^register.html register.php [nc]
RewriteRule ^pre-register.html pre-register.php [nc]
RewriteRule ^login.html login.php [nc]
RewriteRule ^logout.html logout.php [nc]
RewriteRule ^favorites.html favorites.php [nc]
RewriteRule ^contact.html contact.php [nc]
RewriteRule ^listings.html listings.php [nc]
RewriteRule ^pre-submit.html pre-submit.php [nc]
RewriteRule ^refine.html refine.php [nc]
RewriteRule ^([0-9]+)-([^\/]+)?/content.html$ content.php?id=$1 [nc,qsa]
RewriteRule ^([0-9]+)-([^\/]+)?/index.html$ index.php?category=$1 [nc,qsa]
RewriteRule ^([0-9]+)-([^\/]+)?/details.html$ details.php?id=$1 [nc,qsa]
RewriteRule ^([^\/]+)/([^\/]+)/([^\/]+)/recent_ads.html$ recent_ads.php?page=$1&order=$2&order_way=$3 [nc,qsa]
RewriteRule ^([^\/]+)/recent_ads.html$ recent_ads.php?page=$1 [nc,qsa]
RewriteRule ^([0-9]+)-([^\/]+)?/user_listings.html$ user_listings.php?id=$1 [nc,qsa]
RewriteRule ^([0-9]+)-([^\/]+)?/contact_details.html$ contact_details.php?id=$1 [nc,qsa]
RewriteRule ^([0-9]+)-([^\/]+)?/([^\/]+)/([^\/]+)/([^\/]+)/user_listings.html$ user_listings.php?id=$1&page=$3&order=$4&order_way=$5 [nc,qsa]
RewriteRule ^([0-9]+)-([^\/]+)/([^\/]+)/user_listings.html$ user_listings.php?id=$1&page=$3 [nc,qsa]
RewriteRule ^([^\/]+)/([^\/]+)/([^\/]+)/favorites.html$ favorites.php?page=$1&order=$2&order_way=$3 [nc,qsa]
RewriteRule ^([0-9]+)-([^\/]+)?/store.html$ store.php?id=$1 [nc,qsa]
RewriteRule ^([0-9]+)-([^\/]+)?/([^\/]+)/([^\/]+)/([^\/]+)/store.html$ store.php?id=$1&page=$3&order=$4&order_way=$5 [nc,qsa]
RewriteRule ^([0-9]+)-([^\/]+)/([^\/]+)/store.html$ store.php?id=$1&page=$3 [nc,qsa]
在下面的链接中还可以看到,url中使用了过多的%percenta,我是否可以将其更改为其他内容,例如/不更改url的动机,是否可以仅在htaccess中进行更改以实现这一切

.com/147-apartments-for-rent/no_of_rooms-1%20BHK/area_sq_ft-SQFT%20Less%20than%20500/condition_vehicles-New/listings.html .com/147套出租公寓/无房间-1%20BHK/面积-20平方英尺-20平方英尺%20小于%20500/条件车辆-New/listings.html 假设这些都是用来构造url的

{capture name=some_content assign=constructed_url}{$live_site}/listings.php?page=1{foreach from=$post_array key=k item=x name=construct_url}{if $x!='' && $k!=$v.depending.caption2 && $k!=$v.depending.caption3 && $k!=$v.depending.caption4 && $k!="page" && $k!="show" && (!$settings.enable_locations || (!in_array($k, $location_fields) && $k!="crt_city"))}{$separator}{$k}={$x|replace:'/':'--'|urlencode}{assign var="separator" value="&"}{/if}{/foreach}{/capture} {capture name=some_content assign=constructed_url}{$live_site}/listings.php?page=1{foreach from=$post_array key=k item=x name=construct_url}{if$x!=''&$k!=$v.dependent.caption2&$k!=$v.dependent.caption3&$k!=$v.dependent.caption4&$k!=“page”&$k!=“page”&$k!=“show”&$show”&(!$settings.enable|位置($k)&$k)=“crt|u city”)}{$separator}{$k}={$x}替换:'/':'--''''''{assign var=“separator”value=“&”}{/if}{/foreach}{/capture}
代码中需要更改的内容..请不要介意我是编程新手,刚刚开始学习..

当您用其他内容替换链接中的空格时,您可以防止URL中出现
%20
。您必须查看创建URL的源代码(
href=…
src=…
,或其他一些URL创建函数)并使用

$url = str_replace(' ', '-', $url);
在回显
标记之前。

您有以下规则

RewriteRule ^([0-9]+)-([^\/]+)?/content.html$ content.php?id=$1 [nc,qsa]
RewriteRule ^([0-9]+)-([^\/]+)?/index.html$ index.php?category=$1 [nc,qsa]
RewriteRule ^([0-9]+)-([^\/]+)?/details.html$ details.php?id=$1 [nc,qsa]
RewriteRule ^([0-9]+)-([^\/]+)?/user_listings.html$ user_listings.php?id=$1 [nc,qsa]
RewriteRule ^([0-9]+)-([^\/]+)?/contact_details.html$ contact_details.php?id=$1 [nc,qsa]
RewriteRule ^([0-9]+)-([^\/]+)?/store.html$ store.php?id=$1 [nc,qsa]
当您删除
content.html
index.html
details.html
user\u listings.html
contact\u details.html
store.html
时,您将只拥有

RewriteRule ^([0-9]+)-([^\/]+)?/$ ... [nc,qsa]
您如何决定正确的请求是什么?是
content.html
还是
index.html
,可能是
details.html
。但也可能是
store.html


因此,我不知道如何删除
listing.html
details.html
,等等。

请查看我所做的更改,因为我合并了一些行。如果您不同意,请恢复我的更改。我在链接或规则中的任何地方都看不到
page.html
。请澄清您想要什么。哦,对不起,listing.html和detai最后是以结尾的任何内容。html@OlafDietsche我只需要删除上面链接中显示的listing.html和details.html,而不更改url的用途。是否可能。您想删除
listing.html
还是只删除扩展名
.html
%
不仅仅是百分比,而是
%20
,这是URL中空格的结果。有关详细信息,请参阅。@kamalbhardwaj如果您想删除任何
.html
,您必须重新构造URL,并插入一个标识符或一些唯一的数字,以确定这是什么类型的请求。我非常感谢您为让我理解这些内容所做的努力,tha谢谢你。