Hey I've read the sticky on redirection, but didn't find (or I just didn't get it) the info. My urls have changed from www.domain.com/index.php/whatever.html to www.domain.com/whatever.html There are literally thousands of this pages that have changed, so I'm looking for one redirect command that will redirect all index.php to non index.php Can anyone give me an example what to write into my htaccess? Thanks!
Try this: RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^index.php/(.*)$ $1 Code (markup):
@gregberwitz, sorry, but it does not work, I still get a 404. I forgot to say, that its joomla working with sh404, that means that other rewrites are allready in htaccess.
RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^index.php/(.*)$ $1 Options +FollowSymLinks RewriteEngine On RewriteCond %{REQUEST_URI} ^(/component/option,com) [NC,OR] ##optional - see notes## RewriteCond %{REQUEST_URI} (/|\.htm|\.php|\.html|/[^.]*)$ [NC] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule (.*) index.php RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|\%3D) [OR] RewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [OR] RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR] RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR] RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2}) RewriteRule ^(.*)$ index.php [F,L] RewriteCond %{HTTP_HOST} ^debate-motions\.info$ [NC] RewriteRule ^(.*)$ http://www.debate-motions.info/$1 [R=301,L] RewriteEngine on RewriteCond %{HTTP_HOST} ^debate-motions.info$ [OR] RewriteCond %{HTTP_HOST} ^www.debate-motions.info$ RewriteRule ^/index.php?$ http://www.debate-motions.info/index.php?option=com_frontpage&Itemid=1 [R=301,L]
Take what you added out. You don't need the RewriteCond for -f and -d in with this RewriteRule unless you have a real folder named "/index.php/" because they will never match. You don't need RewriteBase because you'll be doing an external redirect with the full URL so that search-engines/visitors can be notified of the address change. What you've tried in this thread is missing a 301 redirect flag on the end nor does it implicitly trigger an external redirect via a full URL in the destination, so instead of being rewritten and immediately directing the visitor to the new URL, it keeps processing. Not good. After the first existing occurance of "RewriteEngine on", you will add the new RewriteRule. Options +FollowSymLinks RewriteEngine On [color=#990000]RewriteRule ^index\.php(/.+)$ http://%{HTTP_HOST}$1 [NC,R=301][/color] RewriteCond %{REQUEST_URI} ^(/component/option,com) [NC,OR] ##optional - see notes## Code (markup):
Hey, joebert thanks tor the explanation, but sadly the links are still showing 404 This is an example of a link that should be rewritten, but it does not get there http://www.debate-motions.info/index.php/Debate-motions/Debate-formats/ it should read http://www.debate-motions.info/Debate-motions/Debate-formats/ EDIT: Just noticed, after I put it where you say it didn't work. So I figured that I should move it, and I moved it after the original rewrite does its job. Now it turns the URL to http://www.debate-motions.info/Debate-formats/ So it takes one step too much out of the URL. Can we change that? Now we are at least on the right way
This needs to be your first Rewrite because you are moving from an old way of doing things to a new way. If you start working with the URL before you've made sure it's not an old-style request, you're going to get unexpected results sooner or later. When it's setup as the first RewriteRule and gives you a 404, what is the address you are trying, and what is the address in the title bar ?
Hey Thanks all for your help, Ill try it aga in and post the URL's in a day or two, a lot of people just visiting the site, so I don't want to mess around with it just now. P.
Looks like a wordpress install. Take a look at Dashboard -> Settings and make sure the two url fields don;t have the index.php in there. Also: http:// htaccess.wordpress.com/2007/12/08/removing-indexphp-with-htaccess/
@theapparatus its a joomla 1.0.13 @joebert, I've added it as the first rewrite. Now I try to go to http://www.debate-motions.info/index.php/Debate-motions/Debate-videos/Zen-debating-2-gov.html and get a 404. The link works ok without the index.php This one is even more interesting, http://www.debate-motions.info/index.php/Debate-motions/EUDC-2008-Tallinn/ redirects to a wrong page, does not give a 404. The link without index.php works without any problems. Thanks!
So, the address you click on, and the resulting address in the bar are the same but you're getting a 404 when the RewriteRule is in place ?