Ad

Want To Hide Page.html In The End Of The Url By Modifying Htaccess

- 1 answer

can somebody help me redirect the url in htaccess. as in the links below its showing page.html in the end, which i want not to appear, is it possible by changing anything in the htaccess, also in many urls % is showing quite a lot, which i also want to change either to / or any other charecter to look appropriately.

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

the htaccess i am using is below:

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]

also see in the link below too many % percenta is getting used in the url, can i change this to something else like / without changing the motive of the url, is it possible to make changes in the htaccess alone for achieving this all?

.com/147-apartments-for-rent/no_of_rooms-1%20BHK/area_sq_ft-SQFT%20Less%20than%20500/condition_vehicles-New/listings.html

suppose this all is bein used to construct 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}

what will need to changed in the code..please don't mind i am new in the line of programming, have just started learning the things....

Ad

Answer

You have these rules

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]

When you remove content.html, index.html, details.html, user_listings.html, contact_details.html and store.html you will have only

RewriteRule ^([0-9]+)-([^\/]+)?/$ ... [nc,qsa]

How do you decide, what the proper request is? Is it content.html or index.html, maybe details.html. But it could also be store.html.

So, I don't see, how you can remove listing.html and details.html, etc.

Ad
source: stackoverflow.com
Ad