mod_rewrite question

Need help installing PHP, configuring a script, or configuring a server? Then come on in and post your questions! We'll try to help the best we can!

Moderator: General Moderators

Post Reply
intellivision
Forum Commoner
Posts: 83
Joined: Mon Aug 22, 2005 1:25 am
Location: Orbit

mod_rewrite question

Post by intellivision »

I'm getting 404's on http://www.appleswitcher.com/blog/

How to rewrite those requests to go to http://www.appleswitcher.com/ ?

And likewise http://www.appleswitcher.com/blog/feed/ to feed://http//www.appleswitcher.com/feed/ ?

Here's my .htaccess currently:

Code: Select all

RewriteEngine On
# BEGIN stats passthru
RewriteBase /
RewriteCond %{REQUEST_URI} ^/stats/(.*)$ [OR]
RewriteCond %{REQUEST_URI} ^/failed_auth.html$
RewriteRule ^.*$ - [L]
# END stats passthru

<IfModule mod_rewrite.c>
RewriteEngine On

# BEGIN product_reviews
RewriteBase /
RewriteCond product_reviews/%{QUERY_STRING} submission=true
RewriteRule product_reviews/mode/([0-9]+)/id/([0-9]+)(/)?$ product_reviews.php?mode=$1&id=$2&flag=2 [L]
RewriteRule product_reviews/mode/([0-9]+)/id/([0-9]+)(/)?$ product_reviews.php?mode=$1&id=$2&flag=1 [L]
# END product_reviews

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress
I tried to do something like

Code: Select all

# BEGIN /blog/ fix attempt
RewriteRule /^blog/$  /index.php [L]
to no avail. I suck at mod_rewrite.[/quote]
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post by Kieran Huggins »

try:

Code: Select all

RewriteRule ^blog/(.*)$  $1 [L]
(I'm no expert)
User avatar
dude81
Forum Regular
Posts: 509
Joined: Mon Aug 29, 2005 6:26 am
Location: Pearls City

Post by dude81 »

This should be a good tutorial for everybody who donno rewrite rules I guess :wink:
http://www.sitepoint.com/article/guide ... writing/2
intellivision
Forum Commoner
Posts: 83
Joined: Mon Aug 22, 2005 1:25 am
Location: Orbit

Post by intellivision »

Thanks KH and dude81 for your help.

K, your's doesn't work.

Dude, I read that tutorial and even another but I still can't get it to work.

I tried the very simple

Code: Select all

RewriteBase /
RewriteRule ^blog/  / [L]
and the more complex

Code: Select all

RewriteBase /
RewriteCond %{REQUEST_URI} ^blog/(.*)$
RewriteRule /$ - [L]
But those still don't rewrite http://www.appleswitcher.com/blog/

Do I need to make an exception to the rules that are already there, instead of another rule?

I'm just not getting anywhere. Could you point me in the right direction?

Thanks,
Confused
User avatar
dude81
Forum Regular
Posts: 509
Joined: Mon Aug 29, 2005 6:26 am
Location: Pearls City

Post by dude81 »

What is the blog software you are using, if it is wordpress :!: , then you need not do anything on rewrite rules.
intellivision
Forum Commoner
Posts: 83
Joined: Mon Aug 22, 2005 1:25 am
Location: Orbit

Post by intellivision »

Yes, WordPress.

My install directory is /blog, but the application writes its own mod_rewrite rules (above, between the "#wordpress" comments) to appear at the root. I configured it this way through the admin panel so as not to clutter the root level with WP files.

So the current rules are working. Except for requests for files in appleswitcher.com/blog, which trigger a 404. It's weird.

That's why I don't know if
a) it should work as is, and something else is messed up or
b) I should add a rule or
c) I should modify an existing rule


thx for the help here.
User avatar
dude81
Forum Regular
Posts: 509
Joined: Mon Aug 29, 2005 6:26 am
Location: Pearls City

Post by dude81 »

I Hope Im not too late,

But still not through with your question properly, sorry for my english,
You mean to say
appleswitcher.com should point to your blog and
appleswitcher.com/blog/ also should point to blog.

If that is the case, I think you need to add a rewrite rule in classes wp_rewrite.
Post Reply