PDA

View Full Version : SE Friendly URLS



My220x
03-28-2009, 02:31 PM
I am using the ForceType method outlined on this site however I can't get it to work, I just get directory not found, can anyone help? Im running xampp for linux.

Chris
03-28-2009, 03:47 PM
Did you do the test?

Open up a regular php file and see if you can access REQUEST_URI.

Also, is this your server or a shared host? It is possible your host turned off this apache feature.

My220x
03-29-2009, 01:47 PM
I put the following:


<?php

echo $_SERVER["REQUEST_URI"];

?>

in a php file and I got the URI.

deathshadow
04-13-2009, 08:45 PM
I really dislike force-type - just because dicking with the mime-type is just making things more complicated to me.

I use mod-rewrite, but I use a different appraoch than the one outlined on this site...


RewriteEngine On

RewriteRule !\.(gif|jpg|png|css|swf|html|js|ico|xml)$ index.php


Basically the above tells the server to reroute all requests EXCEPT files with those extensions to my index.php, from which I handle all operations. You then just explode REQUEST_URI since that does NOT change on a mod-rewrite.

You'll also see I do NOT allow php file requests to be made, redirecting those to index.php - this is a primative security feature of sorts since it prevents apache from allowing users to call any of your libraries independantly.

Chris
04-14-2009, 08:20 AM
I really dislike force-type - just because dicking with the mime-type is just making things more complicated to me.

I use mod-rewrite, but I use a different appraoch than the one outlined on this site...


RewriteEngine On

RewriteRule !\.(gif|jpg|png|css|swf|html|js|ico|xml)$ index.php


Basically the above tells the server to reroute all requests EXCEPT files with those extensions to my index.php, from which I handle all operations. You then just explode REQUEST_URI since that does NOT change on a mod-rewrite.

You'll also see I do NOT allow php file requests to be made, redirecting those to index.php - this is a primative security feature of sorts since it prevents apache from allowing users to call any of your libraries independantly.
That is a pretty good idea for the security aspect.

Chris
04-14-2009, 08:21 AM
I put the following:


<?php

echo $_SERVER["REQUEST_URI"];

?>

in a php file and I got the URI.
So then what is the problem?

Todd W
04-17-2009, 06:36 PM
I do the same as mentioned previously... except I do it like this. Which I believe is how WordPress "SEO Friendly URLS" works too.

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

Not only does it let me pass it all to my index file I can change up my URL structure on the fly as I have an option to set new structure too.