-
Bearded (M|G)od
To remove the index.php part, yes. That's the only way.
-
Gotcha! I will keep this in mind. Thank you.
-
Hi Bud,
Thanks for all the solutions so far, once again. While experimenting with the code in .htaccess file, I stumbled across a new issue. I wanted to basically show pages ending in .php to be rewrited instead of our custom .html files. As such, I modified my .htaccess file to include the following line:
PHP Code:
RewriteRule ^([0-9a-zA-Z_-]+)\.php$ /my_domain/index.php?page_slug=$1 [L]
It gives me the following error:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, webmaster@localhost and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
My Apache Error log says:
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.
Do you have any idea of how I can rewrite .php files to our page slugs instead of using .html files?
Thank you.
-
Bearded (M|G)od
It's causing a loop for one, because you're redirecting to a *.php page. So it enters a loop. What you need to do is add a check to make sure you're requesting a file that doesn't exist.
Also, you can't just use a '.'. '.' means something in regular expressions, so you need to escape it.
Try this out:
Code:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([0-9a-zA-Z_-]+)\.php$ /my_domain/index.php?page_slug=$1 [L]
-
-
Bearded (M|G)od
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
Those are like if statements. It's basically saying: "if the requested filename is not an existing file (!-f) or a directory (!-d), then use the following RewriteRule.
You want that because in your case, you're rewriting a request to say, about.php and rewriting that as index.php?page_slug=about. Well, when you hit that request, it also matched on index.php, causing it to rewrite again as index.php?page_slug=index and so on for your endless loop.
But the catch here is that index.php is an actual file sitting on your server. So the first condition will catch that, and ignore the rewrite.
-
Ahh.. I see.. Thanks much for explaining.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|