htaccess Elite

.htaccess tutorial


All times are UTC [ DST ]





Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Remove directory name from url by .htaccess file
PostPosted: 04 Apr 2008 11:17 
Offline

Joined: 04 Apr 2008 10:50
Posts: 1
i have a site with category listing on home page when i click on a category or subcategory name that shows the items in that category.
url of site is :-
Code:
wholesalehub.com.php5-6.websitetestlink.com/


when click on a category the url looks like this
Code:
siteurl/listing/wholesale-apparel


here wholesale-apparel is category name and that is shown by .htaccess .The eal url is
Code:
siteurl/listing/results.php?category_id=5


the file results.php is resides in listing folder .i want to remove that word /listing from url but the file should be in the listing folder .i have a .htaccess file on root and one in /listing folder.


the code in root htaccess is

Code:
php_value auto_prepend_file /mnt/target02/351049/www.wholesalehub.com/web/content/conf/preconfig.inc.php
RewriteBase /mnt/target02/351049/www.wholesalehub.com/web/content

ErrorDocument 400 /customerrorpage.php
ErrorDocument 401 /customerrorpage.php
ErrorDocument 403 /customerrorpage.php
ErrorDocument 404 /customerrorpage.php
ErrorDocument 500 /customerrorpage.php


the code in /listing/.htaccess is

Code:
RewriteEngine On
RewriteBase /listing

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^(.*/([a-zA-Z0-9_]+)|([a-zA-Z0-9_]+))\.(html|htm)$ [NC]
RewriteRule ^(.*/location|location)/([a-zA-Z0-9_]+)/?([a-zA-Z0-9_]+)?/?([a-zA-Z0-9_]+)?$ ./results.php?country=$2&state=$3&region=$4

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} ^(.*([a-zA-Z0-9-]+)|([a-zA-Z0-9-]+))\.(html|htm)$ [NC]
RewriteRule ^(.*/([a-zA-Z0-9-]+)|([a-zA-Z0-9-]+))\.(html|htm)$ ./detail.php?listing=$1
RewriteRule ^(.*/([a-zA-Z0-9-]+)|([a-zA-Z0-9-]+))\.(html|htm)#([a-zA-Z0-9-]+)$ ./detail.php?listing=$1#2


RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^(.*/([a-zA-Z0-9-]+)|([a-zA-Z0-9-]+))\.(html|htm)$ [NC]
RewriteRule ^(([a-zA-Z0-9-]+)/?([a-zA-Z0-9-]+)?/?([a-zA-Z0-9-]+)?/?([a-zA-Z0-9-]+)?/?([a-zA-Z0-9-]+)?$) ./results.php?category1=$2&category2=$3&category3=$4&category4=$5&category5=$6

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^(.*/([a-zA-Z0-9_]+)|([a-zA-Z0-9_]+))\.(html|htm)$ [NC]
RewriteRule ^(.*/reviews|reviews)/([a-zA-Z0-9_]+)$ ./reviewcomments.php?listing=$2





i have tried a lot but not found any solution.could anybody please help me.


Top
 Profile  
 
 Post subject: Re: Remove directory name from url by .htaccess file
PostPosted: 08 Apr 2008 01:20 
Offline
User avatar

Joined: 25 Sep 2006 04:48
Posts: 242
Change whatever code you are using to remove listing from the pages.

Then redirect all urls with listing in it to the url without listing.

Then rewrite the redirected urls to still use the /listing/results.php


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
cron
Powered by phpBB