Forum Moderators: phranque

Message Too Old, No Replies

Little urgent - problem with mod rewrite

         

lokeshshettyk

3:15 pm on Sep 17, 2008 (gmt 0)

10+ Year Member



Hi,
my main domain is pl.example.com and i am trying to create a subdomain as pl.example.com/iphone. I have few categories, tags and articles in this site since this is a blog. Below is the htaccess file for the same.


# iPhone
RewriteRule ^iphone/?$ /index.php?a=iphone-home&categoryslug=$1 [QSA,L]
RewriteRule ^iphone/([1000-9999]+)/([^/]+)/([^/]+)/([^/]+)/?([0-99]+)?$ /index.php?date=$1/$2/$3&slug=$4&a=iphone-show-post&commentspage=$5 [L,QSA]
RewriteRule ^iphone/category/([^/]+)/?$ /index.php?a=iphone-category&categoryslug=$1 [L]
RewriteRule ^iphone/tag/([^/]+)/?$ /index.php?a=iphone-tag&tag=$1 [L]
#
RewriteRule ^iphone/tag/([^/]+)/page/([0-9999]+)/?$ /index.php?a=iphone-tag&tag=$1&postpage=$2&i=true [L,QSA]
RewriteRule ^iphone/category/([^/]+)/page/([0-9999]+)/?$ /index.php?a=iphone-category&categoryslug=$1&postpage=$2 [L,QSA]
RewriteRule ^iphone/page/([0-9999]+)/?$ /index.php?a=iphone-home&postpage=$1 [QSA,L]

the last 3 rewrites are for pagination. however they don't work.
Now the url shows up as
category - pl.example.com/category/catname/page/pagenum where as it must be pl.engadget.com/iphone/category/catname/page/pagenum
same type of urls must be constructed for tags and articles as well.

Please help

Cheers
Lokesh

[edited by: jdMorgan at 3:31 pm (utc) on Sep. 17, 2008]
[edit reason] Use example.com please. [/edit]

jdMorgan

3:38 pm on Sep 17, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Internal rewrites done with mod_rewrite do not affect how "the URL shows up" -- The URL is defined and controlled by the URLs in the links you present on your pages.

The mod_rewrite code here takes an incoming client-requested URL from a browser (or robot) and points it to your script so that content can be generated and served. This is a URL-to-filename rewrite, and does not affect the client. So if your URLs are "showing up wrong," then you must modify the script that generates those URLs for use in your on-page links, and then perhaps modify your rules above so that these URLs are "connected to" your script to generate the proper page content.

As a general rule, I suggest that you put your rules in order from longest/most-specific-patterns first to shortest/least-specific pattern last. This will avoid unexpected interactions. On review, that is not what is causing the problem here, however.

Jim

lokeshshettyk

3:45 pm on Sep 17, 2008 (gmt 0)

10+ Year Member



Thanks for the quick response, I have another site whicg is i.example.com for which the htaccess(written by someone else) file looks like this

# iPhone
RewriteCond %{HTTP_HOST} ^i\.
RewriteRule ([1000-9999]+)/([^/]+)/([^/]+)/([^/]+)/?([0-99]+)?$ /index.php?date=$1/$2/$3&slug=$4&a=iphone-show-post&commentspage=$5&i=true [L,QSA]
RewriteCond %{HTTP_HOST} ^i\.
RewriteRule ^$ /index.php?i=true&a=iphone-home [L,QSA]
RewriteCond %{HTTP_HOST} ^i\.
RewriteRule ^page/([0-9999]+)/?$ /index.php?a=iphone-home&postpage=$1&i=true [L,QSA]
RewriteCond %{HTTP_HOST} ^i\.
RewriteRule ^category/([^/]+)/page/([0-9999]+)/?$ /index.php?a=iphone-category&categoryslug=$1&postpage=$2 [L,QSA]
RewriteCond %{HTTP_HOST} ^i\.
RewriteRule ^category/([^/]+)/?$ /index.php?a=iphone-category&categoryslug=$1 [L]
RewriteCond %{HTTP_HOST} ^i\.
RewriteRule ^tag/([^/]+)/?$ /index.php?a=iphone-tag&tag=$1 [L]
RewriteCond %{HTTP_HOST} ^i\.
RewriteRule ^tag/([^/]+)/page/([0-9999]+)/?$ /index.php?a=iphone-tag&tag=$1&postpage=$2 [L,QSA]

As I said earlier, since I am pretty new to apache, I am just trying to modify the above for pl.example.com/iphone. Could you please help. I know I am asking for too much, however i am kinda helpless here:)

Thanks so much

[edited by: jdMorgan at 3:55 pm (utc) on Sep. 17, 2008]
[edit reason] Please use example.com only [/edit]

lokeshshettyk

5:48 am on Sep 18, 2008 (gmt 0)

10+ Year Member



If my rewrite condition for [i.example.com...] is RewriteCond %{HTTP_HOST} ^i\. what would be the rewrite condition for [pl.example.com...]

Note : i is the subdomain for example.com and iphone is the subdomain for pl.example.com

Please help. Thanks in advance

[edited by: jdMorgan at 12:37 pm (utc) on Sep. 18, 2008]
[edit reason] Please use example.com only [/edit]

lokeshshettyk

3:31 pm on Sep 18, 2008 (gmt 0)

10+ Year Member



Please help with the above