homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

Htaccess nice url not work

 9:16 am on Mar 11, 2014 (gmt 0)

Next problem from me....
I have web with url:

I want to make url like:

Here's my code:

RewriteRule ^index.(php|html|htm)$ / [R=301,L]
RewriteRule ^([a-z0-9-_]+)/index.(php|html|htm)$ /$1/ [R=301,L]
# here all work i remove index.php and afterr add next web crash :/
RewriteRule ^([^-]*)-([^-]*)-([^-]*)$ /?option=$1&i=$2&sid=$3 [L, R=301]

I know it can be easy for some one, but I try to learn it... ...



 12:40 pm on Mar 11, 2014 (gmt 0)

afterr add next web crash

status code?
message(s) in the web server error log file?


 12:43 pm on Mar 11, 2014 (gmt 0)

Error 500 - Internal Server Error



 12:58 pm on Mar 11, 2014 (gmt 0)

the translation of "Internal Server Error" is usually "go look for a message in the web server error log file".


 1:09 pm on Mar 11, 2014 (gmt 0)

I have only access to ftp :/


 9:07 pm on Mar 11, 2014 (gmt 0)

RewriteRule ^index.(php|html|htm)$ / [R=301,L]

RewriteRule ^([a-z0-9-_]+)/index.(php|html|htm)$ /$1/ [R=301,L]

These are just one rule. With a minimum of changes:

RewriteRule ^([a-z0-9-_]+/)?index\.(php|html?)$ http://www.example.com/$1 [R=301,L,NS]

The target of a redirect always includes the full protocol-plus-host, on the off chance that the user also gave the wrong form of your domain name. (Search engines do this all the time on purpose.) You will also need a preceding RewriteCond looking at {THE_REQUEST}, since some "index.php" requests are the result of internal rewriting (next rule). Here the [NS] flag alone won't be enough, though it's still a good idea.


Surely you don't have URLs that begin with a hyphen? Or that have two consecutive hyphens? Here you want + rather than - each time.

Far more important:
/?option=$1&i=$2&sid=$3 [L, R=301]

That can't possibly be what you want. As written, that's an external redirect from a pretty URL to an ugly one. I have to guess you really want only an internal rewrite: [L] flag alone. Make sure this rule comes after all external redirects: not just the "index.html" redirect that you've shown, but also the domain-name-canonicalization redirect that you haven't shown.

So what I'd expect here is:
RewriteRule ^([^-]+)-([^-]+)-([^-]+)$ /index.php?option=$1&i=$2&sid=$3 [L]
You can rewrite to a raw directory name (no explicit "index.php") but why made mod_dir do the work?

I don't, however, see anything that would create a 500-class error. At most an infinite redirect-- error message from the browser-- if you've got a corresponding redirect from ugly to pretty elsewhere in the code.

I have only access to ftp

Do you mean you don't have access to your raw logs at all? Or only that the logs require sftp: (mine do) and you don't have the right software? Look around; there are plenty of free options.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved