Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Rewriting .php URLs with .htaccess
Old 08-22-2007, 11:25 PM Rewriting .php URLs with .htaccess
downliner's Avatar
Extreme Talker

Posts: 208
Location: Orkney
Trades: 1
I'm hoping someone here can hear out my problem, look at some extracts from my .htaccess files and find the solution (before I throw my pc out the window )

In my sites root directory I used a .htaccess to rewrite all of my URL's to contain the "www". So for example, if someone typed "mydomain.com" it would automatically rewrite it to be "http://www.mydomain.com".

All of my sub-folders are also re-written using the .htaccess file, and it works throughout the site, until we come to the /store/ sub-folder....

My store (powered by Cubecart, who I have already asked for help ) uses a mod that rewrites all products URLs to be search engine friendly, using its own .htaccess file.

There is obviously a clash between the two seperate .htaccess files somewhere, but I can't figure out how to sort it.

I also have a custom mod written that fails to work when the "www" is not included in the URL I have asked the SEO Mod Creator for help with this issue but his advice of merging the two htaccess files did not work as planned (I admit I am a n00b to htaccess).

The contents of my root directories .htaccess file are as follows:

Code:
 RewriteEngine on 
 RewriteCond %{HTTP_HOST} !^www\.mydomain\.co\.uk [NC] 
 RewriteRule ^(.*)$ http://www.mydomain\.co\.uk/$1 [R=301,L]
The contents of my online store .htaccess file, found in root/store/ are as follows:

Code:
RewriteEngine On 
 RewriteCond %{QUERY_STRING} (.+) 
 RewriteRule cat_(.*).html index.php?act=viewCat&catId=$1&%1 [L] 
 RewriteRule cat_(.*).html index.php?act=viewCat&catId=$1 [L] 
 RewriteCond %{QUERY_STRING} (.+) 
 RewriteRule prod_(.*).html index.php?act=viewProd&productId=$1&%1 [L] 
 RewriteRule prod_(.*).html index.php?act=viewProd&productId=$1 [L] 
 RewriteCond %{QUERY_STRING} (.+) 
 RewriteRule info_(.*).html index.php?act=viewDoc&docId=$1&%1 [L] 
 RewriteRule info_(.*).html index.php?act=viewDoc&docId=$1 [L] 
 RewriteCond %{QUERY_STRING} (.+) 
 RewriteRule tell_(.*).html index.php?act=taf&productId=$1&%1 [L] 
 RewriteRule tell_(.*).html index.php?act=taf&productId=$1 [L]
I attempted to merge the two files myself but it did not work as planned. It did successfully add in the "www" at one point, but it changed the directory structure dropping the /store/ from the URL's ~ resulting in lots of 404 Errors....

If anyone is able to work out how to automatically add in the www to ALL of my URLs throughout the store I would be forever greatful, and would of course compensate you for your time with a reward through PayPal and some of that valuable green talkupation (on the hour, every hour for 24 hours unless that breaks WT T&C)

Directory structure is simply:

mydomain.co.uk
mydomain.co.uk/store/

Sorry for such a long message, and apologies for not posting the websites actual domain name but when dealing with .htaccess one must be rather careful. I can of course PM the URL to a longtime member here if they would care to take a look.

Many Thanks,
Will
__________________

Please login or register to view this content. Registration is FREE

Last edited by downliner; 08-22-2007 at 11:26 PM..
downliner is offline
Reply With Quote
View Public Profile Visit downliner's homepage!
 
 
Register now for full access!
Old 08-22-2007, 11:57 PM Re: Rewriting .php URLs with .htaccess
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,918
Name: Keith Marshall
Location: Connecticut
Trades: 0
I think this may work - defining a base for the rewrite mod:

Code:
RewriteEngine On
RewriteBase /store/
RewriteCond %{HTTP_HOST} ^mydomain\.co\.uk [NC]
RewriteRule ^(.*)$ http://www.mydomain.co.uk/$1 [R=301,L]
RewriteRule ^cat_(.*)\.html$ index.php?act=viewCat&catId=$1&%{QUERY_STRING} [L]
RewriteRule ^prod_(.*)\.html$ index.php?act=viewProd&productId=$1&%{QUERY_STRING} [L]
RewriteRule ^info_(.*)\.html$ index.php?act=viewDoc&docId=$1&%{QUERY_STRING} [L]
RewriteRule ^tell_(.*)\.html$ index.php?act=taf&productId=$1&%{QUERY_STRING} [L]
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Old 08-23-2007, 01:24 PM Re: Rewriting .php URLs with .htaccess
downliner's Avatar
Extreme Talker

Posts: 208
Location: Orkney
Trades: 1
Thank you for the reply but unfortunately it didn't work I'm not sure that I did everything correctly however.

I replaced all of my code in my stores current .htaccess file with that that you posted. That resulted in products returning a "Not Found" document, it also didn't add in the www's

Any further advice would be greatly appreciated, I am totally stuck on this one
__________________

Please login or register to view this content. Registration is FREE
downliner is offline
Reply With Quote
View Public Profile Visit downliner's homepage!
 
Old 08-23-2007, 01:43 PM Re: Rewriting .php URLs with .htaccess
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,918
Name: Keith Marshall
Location: Connecticut
Trades: 0
I'm wondering since you use a subdirectory if the rewrite are wrong.

Code:
RewriteEngine On
RewriteBase /store/
RewriteCond %{HTTP_HOST} ^mydomain\.co\.uk [NC]
RewriteRule ^(.*)$ http://www.mydomain.co.uk/$1 [R=301,L]
RewriteRule cat_(.*)\.html$ index.php?act=viewCat&catId=$1&%{QUERY_STRING} [L]
RewriteRule prod_(.*)\.html$ index.php?act=viewProd&productId=$1&%{QUERY_STRING} [L]
RewriteRule info_(.*)\.html$ index.php?act=viewDoc&docId=$1&%{QUERY_STRING} [L]
RewriteRule tell_(.*)\.html$ index.php?act=taf&productId=$1&%{QUERY_STRING} [L]
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Old 08-23-2007, 07:57 PM Re: Rewriting .php URLs with .htaccess
downliner's Avatar
Extreme Talker

Posts: 208
Location: Orkney
Trades: 1
Thank you again for the response but unfortunately still no luck

I uploaded your .htaccess code but the following happened:

When I tried going directly to "mydomain.co.uk/store/" it redirected me to the homepage as "http://www.mydomain.co.uk" (without the /store/)

If I tried to access a product directly, for example:

mydomain.co.uk/store/category/product.html

It returned a page not found error. The URL had been rewritten to:

mydomain.co.uk/category/product.hml (note, without the /store/ directory)

I do appreciate your time and again would be greatful for any other ideas.
Many Thanks
Will
__________________

Please login or register to view this content. Registration is FREE
downliner is offline
Reply With Quote
View Public Profile Visit downliner's homepage!
 
Reply     « Reply to Rewriting .php URLs with .htaccess
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.15562 seconds with 12 queries