•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Web Developers' Lounge section within the Web Development category of DaniWeb, a massive community of 392,083 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,942 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Web Developers' Lounge advertiser:
Views: 1821 | Replies: 2
![]() |
•
•
Join Date: Sep 2006
Posts: 2
Reputation:
Rep Power: 0
Solved Threads: 0
I'm using media temple grid-server hosting, and I think it has a very particular way of handling htaccess files, which I haven't figued out yet.
This is what I want to do:
make
domain.com/index.php/something/
look like
domain.com/something/
The code I currently have if this:
Options +Indexes +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteRule ^(.*)/$ index.php/$1 [L]
That's the only way it works. I get rid of the / in ^(.*)/$ or put a question mark besides it and it will stop working. I've tried codes so it excludes real directories and files, but it will stop working. Also, I wanted it to be able to work with or without a trailing slash at the end of the URL, I've tried all kinds of codes, and again, it will just stop working.
If someone could pleeasee help me I would appreciate it a lot. I've been trying to figure this out for months now.
This is what I want to do:
make
domain.com/index.php/something/
look like
domain.com/something/
The code I currently have if this:
Options +Indexes +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteRule ^(.*)/$ index.php/$1 [L]
That's the only way it works. I get rid of the / in ^(.*)/$ or put a question mark besides it and it will stop working. I've tried codes so it excludes real directories and files, but it will stop working. Also, I wanted it to be able to work with or without a trailing slash at the end of the URL, I've tried all kinds of codes, and again, it will just stop working.
If someone could pleeasee help me I would appreciate it a lot. I've been trying to figure this out for months now.
domain.com/index.php/something/
Well can't you use the
/ as a delimiter to split the string into three parts.1.domain.com
2.index.php <-- Don't print this
3.something
http://www.phpbuilder.com/manual/en/function.split.php
Then you can just omit printing the second bit? Or am I underestimating what you want it to do?
•
•
•
•
Also, I wanted it to be able to work with or without a trailing slash at the end of the URL
I suppose you could use regex...
.{1,}(/|[a-zA-Z])$Possibly - not tested?
Last edited by iamthwee : Mar 12th, 2007 at 3:46 pm.
Member of: F-ugly code club
Join today don't delay!
Join today don't delay!
•
•
Join Date: Jul 2006
Location: Deptford, London
Posts: 936
Reputation:
Rep Power: 5
Solved Threads: 47
If you check your Apache errorlog file when running the code you want (i.e. the same, without the / or with a /?) ; then you'll see a line like this:
Simply; if you run a redirect for (.*); it will match for every request; including the internal requests for index.php. I didn't use "LogLevel debug" as that error message suggests; but it will do something like:
etc; until it reaches the"LimitInternalRecursion" setting.
There's probably more than one way to prevent this; but, here is a way:
The RewriteCond line prevents any redirects where the request URI begins with /index.php. REQUEST_URI (URI not URL) is a server environment variable, and its set fresh for every request, to the path from the document root to the requested 'file'. it's important that you take the preceding slash into account.
The RewriteRule is pretty much the same as you had; except it doesn't need a '/' and it uses the QueryStringAppend flag; (means you should be able to silently pass QueryString variables into the redirected request; but, it might not be neccessary; that depends entirely on how Apache handles internal redirection.)
Like I say, there could be other ways; I been messing around for the past half hour trying to find a cleaner solution; but, thought I'd share this with you for the time being..
•
•
•
•
Originally Posted by Apache
[Fri Mar 16 00:54:31 2007] [error] [client 127.0.0.1] Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace., referer: http://127.0.0.1/whatever
Simply; if you run a redirect for (.*); it will match for every request; including the internal requests for index.php. I didn't use "LogLevel debug" as that error message suggests; but it will do something like:
request: /something redirect 1: /index.php/something redirect 2: /index.php/index.php/something redirect 3: /index.php/index.php/index.php/something
There's probably more than one way to prevent this; but, here is a way:
Options +Indexes +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^\/index\.php(.*)$
RewriteRule ^(.*)$ index.php/$1 [QSA,L]The RewriteCond line prevents any redirects where the request URI begins with /index.php. REQUEST_URI (URI not URL) is a server environment variable, and its set fresh for every request, to the path from the document root to the requested 'file'. it's important that you take the preceding slash into account.
The RewriteRule is pretty much the same as you had; except it doesn't need a '/' and it uses the QueryStringAppend flag; (means you should be able to silently pass QueryString variables into the redirected request; but, it might not be neccessary; that depends entirely on how Apache handles internal redirection.)
Like I say, there could be other ways; I been messing around for the past half hour trying to find a cleaner solution; but, thought I'd share this with you for the time being..
Last edited by MattEvans : Mar 15th, 2007 at 9:30 pm. Reason: capitalizing URI to make it look less like URL
If it only works in Internet Explorer; it doesn't work.
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb Web Developers' Lounge Marketplace
•
•
•
•
adult advertising blog browser browsers browsing community data design development devices domains firefox google html india internet java legal linux marketing math merger microsoft mobile applications mozilla msn multimedia news php privacy report research search security sex social networking software technology users video w3c web web development wiki wikipedia xml yahoo youtube
- Disable access to .htaccess (Linux Servers and Apache)
- .htaccess not working.! (Linux Servers and Apache)
- .htaccess mod_rewrite problem (Linux Servers and Apache)
Other Threads in the Web Developers' Lounge Forum
- Previous Thread: Online Community Website/Social Networking site
- Next Thread: Which technologies for optimum site?



Linear Mode