Jump to content

Recommended Posts

Posted

So, I started reading up on this... what I want to do is replace urls that look like

 

>mysite.com/index.php?go=archives/000001.html

 

to something like, maybe:

 

>mysite.com/index.php/go/archives/000001.html

 

Also, I've noticed the IE doesn't always add the trailing slash, which messes up my images... anyway mod_rewrite can fix that?

 

So...I'm trying to figure this out...any suggestions?

Posted

Looking at some of my rewrites if it a simple one it may be as simple as

 

RewriteRule ^archives.html index.php?go=archives

 

Just something to try, I dont know much about the rewrite yet and am still learning about all of the commands for .htaccess

Posted

This is what I have...it's not working though... and unfortunately, I can't find much information out ther that I can understand :D

 

>RewriteCond %{QUERY_STRING} ^go=/(.*)$ 
RewriteRule ^index\.php$ /columns/%1? [L]

 

 

I was hoping that would rewrite

 

subdomain.mysite.com/index.php?go=archives/001.html

 

to

 

subdomain.mysite.com/columns/archives/001.html

 

I just want the search enginges to be able to crawl my dynamic pages....I'll see if what you're using can help me Thumbs Up

 

Justin

Posted

>RewriteCond %{QUERY_STRING} ^go=(.*)$ 
RewriteRule ^index\.php$ /columns/%1? [L]

 

The above seems to work better, now, when I click on my un-rewritten URLs, it processes it and tries to re-write the URL to what I want... but, I still get the 404 errors...

 

Any help here? Maybe I should post this in the scripting forum?

 

Justin

Posted

Boxfire-

 

Sorry, I won't be much help -- I know just enough about mod_rewrite to ask if it's enabled. But, I looked at the apache docs for it, and wow, we could get into some real trouble with this thing! :)

 

Still, your rewrite rule looks okay... so it does it rewrite a URL that looks correct? But still gives a 404? What if you add the "R" flag to force the redirect, so it looks like:

 

>RewriteCond %{QUERY_STRING} ^go=(.*)$
RewriteRule ^index\.php$ /columns/%1? [R,L]

 

Otherwise, I'm empty -- time for a big review of my regexps.

 

-Alan

Posted

I could never in my entire life write anything at all that would use mod_rewrite and work. I use regexp all the time in the scripts that parse XML and HTML, I use all other Apache modules, but this one has been nothing but pain for me.

 

I've learned the tutorials by heart now but still can't understand a damned thing.

 

I gave up. I hate it.

Posted

Heres a cut n paste frompart of my htaccess, I have NO clue how mod_rewrite works, but maybe this will help.

 

 

>RewriteEngine on

#The next lines check for Email Spammers Robots and redirect them to a fake page
RewriteCond %{HTTP_USER_AGENT} ^Alexibot                [OR]
RewriteCond %{HTTP_USER_AGENT} ^asterias                [OR]
RewriteCond %{HTTP_USER_AGENT} ^BackDoorBot             [OR]
RewriteCond %{HTTP_USER_AGENT} ^Black.Hole              [OR]
RewriteCond %{HTTP_USER_AGENT} ^BlackWidow              [OR]
RewriteCond %{HTTP_USER_AGENT} ^BlowFish                [OR]
RewriteCond %{HTTP_USER_AGENT} ^BotALot                 [OR]
RewriteCond %{HTTP_USER_AGENT} ^BuiltBotTough           [OR]
RewriteCond %{HTTP_USER_AGENT} ^Bullseye                [OR]
RewriteCond %{HTTP_USER_AGENT} ^BunnySlippers           [OR]
RewriteCond %{HTTP_USER_AGENT} ^Cegbfeieh               [OR]
RewriteCond %{HTTP_USER_AGENT} ^CheeseBot               [OR]
RewriteCond %{HTTP_USER_AGENT} ^CherryPicker            [OR]
RewriteCond %{HTTP_USER_AGENT} ^ChinaClaw               [OR]
RewriteCond %{HTTP_USER_AGENT} ^CopyRightCheck          [OR]
RewriteCond %{HTTP_USER_AGENT} ^cosmos                  [OR]
RewriteCond %{HTTP_USER_AGENT} ^Crescent                [OR]
RewriteCond %{HTTP_USER_AGENT} ^Custo                   [OR]
RewriteCond %{HTTP_USER_AGENT} ^DISCo                   [OR]
RewriteCond %{HTTP_USER_AGENT} ^DittoSpyder             [OR]
RewriteCond %{HTTP_USER_AGENT} ^Download\ Demon         [OR]

RewriteCond %{HTTP_USER_AGENT} ^WWWOFFLE                [OR]
RewriteCond %{HTTP_USER_AGENT} ^Xaldon\ WebSpider       [OR]
RewriteCond %{HTTP_USER_AGENT} ^Xenu's                  [OR]
RewriteCond %{HTTP_USER_AGENT} ^Zeus
RewriteRule ^.*$ emailsforyou.php  [L]

#RewriteCond %{HTTP_USER_AGENT}  ^-?$
#RewriteRule ^.*$ /www/nukecops/noID.php [L]

RewriteRule ^index.html index.php

#Articles
RewriteRule ^article-([0-9]*)-([a-z]*)-([0-9]*)-([0-9]*).html modules.php?name=News&file=article&sid=$1&mode=$2&order=$3&thold=$4
RewriteRule ^article-([0-9-]*)-([a-z]*)-([0-9]*)-([0-9]*).html([0-9#]*) modules.php?name=News&file=article&thold=$1&mode=$2&order=$3&sid=$4$5
RewriteRule ^article-topic([0-9]*)-page([0-9]*).html modules.php?name=News&new_topic=$1&pagenum=$2
RewriteRule ^article-category([0-9]*)-page([0-9]*).html modules.php?name=News&file=categories&op=newindex&catid=$1&pagenum=$2
RewriteRule ^article-category-([0-9]*).html modules.php?name=News&file=categories&op=newindex&catid=$1
RewriteRule ^article-print-([0-9]*).html modules.php?name=News&file=print&sid=$1
RewriteRule ^article-friend-([0-9]*).html modules.php?name=News&file=friend&op=FriendSend&sid=$1
RewriteRule ^article-page-([0-9]*).html modules.php?name=News&pagenum=$1
RewriteRule ^article([1-9][0-9]*).* modules.php?name=News&file=article&sid=$1
RewriteRule ^article-topic-([0-9]*).html modules.php?name=News&new_topic=$1
RewriteRule ^allnews.html modules.php?name=News&file=allindex
RewriteRule ^news.html modules.php?name=News

#AvantGo
RewriteRule ^avantgo-print-([0-9]*).html modules.php?name=AvantGo&file=print&sid=$1
RewriteRule ^avantgo.html modules.php?name=AvantGo

#Content
RewriteRule ^content-([0-9]*)-page([0-9]*).html modules.php?name=Content&pa=showpage&pid=$1&page=$2
RewriteRule ^content-cat-([0-9]*).html modules.php?name=Content&pa=list_pages_categories&cid=$1
RewriteRule ^content-([0-9]*).html modules.php?name=Content&pa=showpage&pid=$1
RewriteRule ^content.html modules.php?name=Content

Posted

Boxfire-

 

I note that your rewriterule

 

>RewriteRule ^index\.php$ /columns/%1? [L]

 

Looks almost like an inverse of Mike's:

 

>RewriteRule ^content-cat-([0-9]*).html modules.php?name=Content&pa=list_pages_categories&cid=$1
RewriteRule ^content-([0-9]*).html modules.php?name=Content&pa=showpage&pid=$1
RewriteRule ^content.html modules.php?name=Content

 

That is, the search engine-friendly part of the rewritten URL looks like it comes first in Mike's rules, followed by the dynamic (php in this case) part of the URL. So, what happens if you switch the order, to something like

 

>RewriteRule ^/columns/%1 index\.php?

 

-Alan

Posted

Thanks everyone...I'll try some of these suggestions and see if what works...

 

I am getting it to rewrite the URL, I think, I still get the 404 error.

 

When I click on one of my normal URL's, it tells me it can't find the re-written URL...so, maybe that means I'm on the right track.

 

Justin

Posted

Okay, I've tried and tried and tried, nothing works. It seems that it rewrites the URL, but I still get the 404 error.

 

I didn't mention this before, but index.php is basically a design container... I use the script

 

 

 

><?php 
  if (isset($go)) {
    include("$go");
  } else {
  include("filename.html");
}
?>

 

to pull in static html files to have a complete page...is there something I might be missing about using this script and mod_rewrite?

 

Also, I've heard there's a way to rewrite the URL using PHP only...anyon know about that?

 

Justin

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...