2
votes

I have a site that I would like to use Apache's RewriteRule to rewrite URLs. I want:

I have AMPPS installed on my Mac and I added the following lines to httpd.conf and they work successfully:

RewriteEngine On
RewriteRule ^/p/(.*) /index.php?p=$1 [PT]

I'm trying to do the same but on my server. And I have added the same apache code to /public_html/.htaccess but I get the error message below:

Not Found
The requested URL /p/home was not found on this server. Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

The exact same code works on my localhost server. Why not on my website?

3

3 Answers

5
votes

Can you check your remote server apache supports "AllowOverride All" ?

also try this way maybe it will help.

RewriteEngine On
RewriteRule ^p/(.*) /index.php?p=$1 [PT]

but you may have to modify $_GET['p'] properly. which will be sent only "home" part.

3
votes

You need to remove the leading slash from the rewrite rule's pattern. URI's have their leading slash removed when the rewrite engine applies rules in an htaccess file.

RewriteEngine On
RewriteRule ^p/(.*) /index.php?p=$1 [PT]
1
votes
<IfModule mod_rewrite.c>

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.baileyseymour\.com
RewriteRule ^(.*)$ http://www.baileyseymour.com/$1 [R=301,L]

</IfModule>

.htaccess is the right place to put them and that file should be in the same directory as your default home page.