Jump to content

Recommended Posts

Hello

 

By editing my .htaccess file, and enabling mod_rewrite, i have made it possible to use urls like this: http://www.example/funny-videos/ass-catches-on-fire and i can get the right content by exploding() the url.

 

My .htaccess file:

 

RewriteEngine On

RewriteRule ^([^/]*)/([^/]*)$ /index.php?category=$1&trim=$2 [L]

 

 

This thing works fine, but i'm a little worried about the search engines, because if a user misspells the address and no content matches the url, the user will still not get a 404 error. Basically, it is impossible right now to generate a 404 error on my website. From what i've heard, this is a bad think when considering search engine rankings. This could probably also generate a lot of dublicate content.

 

On my website right now, i have 3 categories: funny-videos, funny-pictures and free-wallpapers.

 

Is it in any way possible to use the rewrite rule, only if one of these categories is in the url, and if not, use errordocument? I tried using {QUERY_STRING}, but from what i can gather, this only works if the url has variables in it with ? and =.

 

I've tried and tried, and spent days searching for information on this, but it seems that .htaccess information is lacking.

 

Any help would be very much appreciated.

You will want to do that processing in your script that gets the category and trim url variables. I guess you are using a database. SO what you will want to do is have a an if statement that checks to see how results was returned from the database, if its 1 then display the content that corresponds to the url vars. If its 0 then use die() and include() together to include your 404 error page.

Thanks for the reply

 

I have tried using errorcodument in htaccess to redirect all requests to a 404 handler script. This worked fine, but all the pages had a 404 header. So basically, eventhough i had content to match the url, every single page would say not found in the header, and from what i understand, this is not a very good option when considering search engine indexing.

 

I must admit that using errordocument instead of mod rewrite was a lot easier, but i'm really worried about all the pages showing a 404 header. I'm not sure if google will index such pages.

 

If i use ErrorDocument 404 /handler.php in my htaccess file, and try to proccess the url's there to find the content, is it then possible to show the 404 header, only if no content was found?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

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

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.