htaccess and mod_rewrite redirect error - php

on ubuntu 13.04 and apache2 and php 5.4 i got the 404 error.
mod rewrite is enabled on my machine
my .htaccess code is like this:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^/dl/([0-9]+)/$ dl.php?id=$1
</IfModule>
and the dl.php is set up for just echo the variables:
<?php
print_r($_GET);
?>
on output when i will go to this address http://localhost/digidoc/dl/5 it shows the 404 error
p.s.:the .htaccess file included in digidoc folder and digidoc folder is in web server root

Change
RewriteRule ^/dl/([0-9]+)/$ dl.php?id=$1
Into
RewriteRule ^/digidoc/dl/([0-9]+)/?$ dl.php?id=$1
Notice the ?, so the last slash is optional. Also add digidoc/ as the rule is applied to the whole url.

You need to get rid of the leading slash:
Options -Multiviews
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /digidoc/
RewriteRule ^dl/([0-9]+)$ dl.php?id=$1 [L,QSA]
</IfModule>
You should also include a rewrite base as well as making sure that you have multiviews turned off.

Related

how to use multiple url RewriteRule in .htaccess

this is working
RewriteRule ^([a-zA-Z0-9_-\s]+)-([a-zA-Z0-9_-\s]+)\.html$ detail.php?category=$1&model=$2
this is working
RewriteRule ^([a-zA-Z0-9_-\s]+)\.html$ brand.php?brand=$1
this is not working
RewriteRule ^([a-zA-Z0-9_-\s]+)\.htm$ colour.php?colour=$8
only two rule working how to use multiple rewrite rule using .htaccess
if i use like this ^colour/([a-zA-Z0-9_-\s]+)\.htm$ colour.php?colour=$1 then it is working with out colour/ this it is not working
This problem seems to be due to enabling of MultiViews. Option MultiViews is used by Apache's content negotiation module that runs before mod_rewrite and and makes Apache server match extensions of files. So /file can be in URL but it will serve /file.php.
To disable this use this line at top of your .htaccess:
Options -MultiViews
RewriteEngine On
RewriteBase /
RewriteRule ^colour/([\w\s-]+)\.htm$ colour.php?colour=$1 [L,QSA,NC]

mod re write help - WAMP

Looking to re write a url in WAMP. I have AllowOverride Al (conf file). The mod rewrite modules is loaded. I am working on localhost
What i want to acheive is that on login the user gets redirected
localhost/propcms/xxxxxxx/
the actual address is
localhost/propcms/status.php?id=xxxxxxx
the .htaccess file has the following (and is located in localhost/propcms/ )
Options +FollowSymlinks
RewriteEngine on
RewriteBase /propcms/
RewriteRule ^propcms/([^/]*)/$ /propcms/status.php?id=$1 [L]
this is what i get....The requested URL /propcms/test121/ was not found on this server.
any ideas ??
Since you are specifying a rewritebase, you should not include it in your rewrite rule:
Try this snippet :
Options +FollowSymlinks
RewriteEngine on
RewriteBase /propcms/
RewriteRule ^([^/]*)/$ /propcms/status.php?id=$1 [L]

Apache rewrite rule works on localhost but not on server

I have a site that I would like to use Apache's RewriteRule to rewrite URLs.
I want:
http://baileyseymour.com/index.php?p=home
to rewrite to
http://baileyseymour.com/p/home
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?
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.
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]
<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.

.htaccess modrewrite not redirecting my links

I'm changing my website links to a SEO friendly urls, I did every thing in php file and changed the urls as following:
http://mywebsiet.com/news-details.php?id=2012/6/21/newstitle.html
how can I redirect to:
http://mywebsiet.com/2012/6/21/newstitle.html
I tried this Generating tool from www.generateit.net/mod-rewrite/
and created the .htaccess with the code provided:
RewriteEngine On
RewriteRule ^([^_]*)$ /news-details.php?id=$1 [L]
and even so, nothing get changed.... any ideas?
Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteRule ^(.+?\.html)$ /news-details.php?id=$1 [L,QSA,NC]

install fuelphp 403 error

I have downloaded fuel unzipped it and placed it in a virtual host(virtual hostX) it comes up as fuel.site
but not the welcome page it just comes up a directory listing
changelog.md
docs(folder)
oil
if I try and go manually to the public folder I get a 403 error
what do I need to configure to get it to run?
I even tried a .htaccess file with
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /fuel/public
RewriteRule ^(.*)$ /fuel/public/public/index.php/$1 [L]
</IfModule>
in it as recommended on another site
If you can't find the answer here: http://docs.fuelphp.com/installation/instructions.html#manual
Could you show me the dir/filestructure? The public/public seems a bit off. And the rewrite base should probably just be /. Like this:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteRule ^(.*)$ /fuel/public/index.php/$1 [L]
# Sometimes it's: RewriteRule ^(.*)$ /fuel/public/index.php?/$1 [L]
</IfModule>
sorry guys i had some errors in my apache setup using mamp now working fine thanks for the help

Categories