Web Hosting Talk







View Full Version : .htaccess to *.com/index.php/example


shally87
03-12-2010, 02:36 PM
I am using wordpress and currently i have problem with visitor getting error 404 by visiting http://www.example.com/xxx
since the real page was in http://www.example.com/index.php/xxx

Below is my rewrite rules and in bold is what I make.. hope some one can help me out.


# BEGIN WPSuperCache
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
AddDefaultCharset UTF-8
RewriteCond %{REQUEST_URI} !^.*[^/]$
RewriteCond %{REQUEST_URI} !^.*//.*$
RewriteCond %{REQUEST_METHOD} !POST
RewriteCond %{QUERY_STRING} !.*=.*
RewriteCond %{HTTP:Cookie} !^.*(comment_author_|wordpress|wp-postpass_).*$
RewriteCond %{HTTP_USER_AGENT} !^.*(2.0\ MMP|240x320|400X240|AvantGo|BlackBerry|Blazer|Cellphone|Danger|DoCoMo|Elaine/3.0|EudoraWeb|Googlebot-Mobile|hiptop|IEMobile|KYOCERA/WX310K|LG/U990|MIDP-2.|MMEF20|MOT-V|NetFront|Newt|Nintendo\ Wii|Nitro|Nokia|Opera\ Mini|Palm|PlayStation\ Portable|portalmmm|Proxinet|ProxiNet|SHARP-TQ-GX10|SHG-i900|Small|SonyEricsson|Symbian\ OS|SymbianOS|TS21i-10|UP.Browser|UP.Link|webOS|Windows\ CE|WinWAP|YahooSeeker/M1A1-R2D2|iPhone|iPod|Android|BlackBerry9530|LG-TU915\ Obigo|LGE\ VX|webOS|Nokia5800).*
RewriteCond %{HTTP:Accept-Encoding} gzip
RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html.gz -f
RewriteRule ^(.*) /wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html.gz [L]

RewriteCond %{REQUEST_URI} !^.*[^/]$
RewriteCond %{REQUEST_URI} !^.*//.*$
RewriteCond %{REQUEST_METHOD} !POST
RewriteCond %{QUERY_STRING} !.*=.*
RewriteCond %{HTTP:Cookie} !^.*(comment_author_|wordpress|wp-postpass_).*$
RewriteCond %{HTTP_USER_AGENT} !^.*(2.0\ MMP|240x320|400X240|AvantGo|BlackBerry|Blazer|Cellphone|Danger|DoCoMo|Elaine/3.0|EudoraWeb|Googlebot-Mobile|hiptop|IEMobile|KYOCERA/WX310K|LG/U990|MIDP-2.|MMEF20|MOT-V|NetFront|Newt|Nintendo\ Wii|Nitro|Nokia|Opera\ Mini|Palm|PlayStation\ Portable|portalmmm|Proxinet|ProxiNet|SHARP-TQ-GX10|SHG-i900|Small|SonyEricsson|Symbian\ OS|SymbianOS|TS21i-10|UP.Browser|UP.Link|webOS|Windows\ CE|WinWAP|YahooSeeker/M1A1-R2D2|iPhone|iPod|Android|BlackBerry9530|LG-TU915\ Obigo|LGE\ VX|webOS|Nokia5800).*
RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html -f
RewriteRule ^(.*) /wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html [L]
</IfModule>
# END WPSuperCache

# BEGIN WordPress
<IfModule mod_rewrite.c>

RewriteCond %{THE_REQUEST} ^[^/]*/index\.php [NC]
RewriteRule . / [R=301,L]


# www.example.com/xxx to www.example.com/index.php/xxx
#RewriteRule ^http://www.example.com/(.*) http://www.example.com/index.php/$1 [NC]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

</IfModule>


I also wondering if there is conflict in both the italicized code?

Driver01
03-12-2010, 04:18 PM
Not entirely sure of the question but first # means comment, therefore anything with # preceding it will be ignored, secondly why would you need to do that, index.php is a file not a directory so you would write www.domain.com/directory/file or www.domain.com/directory will load the directories index file if it has one?

globalcsolutions
03-13-2010, 02:56 AM
it seems that you comment the entry for

#RewriteRule ^http://www.example.com/(.*) http://www.example.com/index.php/$1 [NC]

shally87
03-13-2010, 11:36 AM
sorry, I did not comment it before..
it was
RewriteRule ^http://www.example.com/(.*) http://www.example.com/index.php/$1 [NC]
and still not functioning.. how long till the changes effect my file if i do the changes? immediately or sooner? Since every time i rewrite I directly clear my cache and try it out.

Driver01
03-13-2010, 11:52 AM
have you got a directory called index.php in your tree?

If not then this will not work becuase your telling it to go to a url that doesn't exist.

The 404 or Not Found error message is an HTTP standard response code indicating that the client was able to communicate with the server but the server could not find what was requested

shally87
03-13-2010, 01:48 PM
yes, there was index.php files. Without redirection all my post would be redirecting to http://www.example.com/index.php/xxx, but since my old host have it http://www.example.com/xxx, and i have to avoid broken links so, for any request http://www.example.com/xxx i wanted to redirect it to http://www.example.com/index.php/xxx

Driver01
03-13-2010, 02:34 PM
maybe I don't quite understand?, index.php is a file not a directory/folder as you have it in the url the browser is looking for a directory/folder called 'index.php'. this '/' in the uri is a directory/folder seperator.
So if I put this:

http://www.example.com/index.php

the browser would look for the file index.php in the base directory

if I put this:

http://www.example.com/index.php/

the browser would look for a directory or folder called 'index.php' in the base directory, and would try to load an index file in that directory/folder.

redirection can be accomplished through cpanel if you have that, it will add it automatically for you.

shally87
03-13-2010, 07:19 PM
Owh owh XD. Its a index.php file anyway. this is the first time I get into this problem too.
I just not quite get it since in wordpress we have the ability to redirect by using permalinks as to make a google friendly site.
It sort of work as a folder but there is no index.php/ folder. From what I see in manual script too it sometimes ends with index.php?xxx or something alike.
When I try to remove the index.php from the www.example.com/index.pxp/xxx and make it like www.example.com/xxx it really did not work.

kenji.lee
03-13-2010, 08:07 PM
RewriteRule ^http://www.example.com/(.* (http://www.example.com/%28.*)) http://www.example.com/index.php/$1 [NC]

Not work ... :D I think it will reidrect forever ...

Use this :
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

It will put everything if not exist files or folder to index.php
reply if u have any question.