Options +FollowSymlinks
RewriteEngine on
RewriteRule ^WR-(.*)\.html$ WR.php?act=show
i have created .htaccess file to rewrite WR.php?act=show to .html extension and save this file in a folder where my source file are residing. but it is not working can anybody help me please....
try this htaccess rule generator
or this,
these will definitely help you a lot.
The rule looks fine to me. Copying and pasting into a .htaccess on my own server redirects WR-foo.html to WR.php?act=show as expected.
Depending on what exactly is happening (are you seeing an error? is it just not redirecting? redirecting to the wrong place? etc), you might want to try enabling logging for mod_rewrite. See the RewriteLog directive (and RewriteLogLevel just below that). The Apache error log is also always worth a look.
Related
My htaccess file code is not working even it is right i found on many website for this each website has same code here it is :-
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^products/([a-zA-Z]+)/([0-9]+)/$ index.php?action=$1&sub_cat=$2
now this thing is not working www.example.com/products/something/3/
anything else i am forgetting please help me.
Because you have a products.php file and your URL looks like www.example.com/products/something/3/, a module called "mod_negotiation" is processing the request before mod_rewrite can. The Multiviews option will allow mod_negotiation to try to "guess" what a request is for, and it sees /products/ in the URL and the file /products.php and assumes that's what the request is for, serves the request via the products.php script and mod_rewrite never gets a chance to do anything.
Solution?
Turn off multiviews:
Options -Multiviews
by adding that option anywhere in your htaccess file.
My application worked with .htaccess when it was on localhost
When I uploaded the application to the server, the .htaccess is not working.
Through phpinfo(); I noticed that mod_rewrite is loaded under apache2handler.
I suspect my .htaccess rule maybe wrong, so I tested with
http://www.webune.com/forums/viewtopic-p-62.html
but it still didnt work, the 404 page is showed.
What should be the valid reasons for above problem?
Thank you so much for your help :)
I would guess that AllowOverride is set to None or something that is preventing you from controlling mod_rewrite within an .htaccess file. You're going to need to be able to modify Apache's config to change that.
Here's how you test it: How To Check If mod_rewrite is Enabled in Apache
If you have access to your Apache config files, look at http://httpd.apache.org/docs/2.1/howto/htaccess.html.
Check the AccessFileName parameter if it is .htaccess. It should be by default. If it is, then it is a problem with the site configuration. Refer to Jonathan's answer for that solution.
I type xyz.com/1234(1234 is jargon) it takes me to xyz.com/index.php. I am using apache and mod_rewrite does not have any rule for this .Index page is not even the default page setup by the DirectoryIndex.I am puzzled why it takesto the index page.
Try whether it gets better with
Options -Multiviews
in the .htaccess file. If it doesn't, there must be a rewrite rule somewhere, or maybe an ErrorDocument directive (although that shouldn't redirect).
You can see if it's mod_rewrite doing it to you easily by cranking up rewrite logging to insane levels:
RewriteEngine On
RewriteLogLevel 10
RewriteLog "/var/log/apache2/rewrite.log"
Post your apache config and the relevant .htaccess file and we might be able to be more help.
Please how can I rewrite
Could anybody please rewrite this url?
http://localhost/display_news_cat.php?news_cat_id=14&p=2
to
http://localhost/display_news_cat/14/2
Thank you
Create an .htaccess file in the site directory and add the following lines
RewriteEngine on
RewriteRule ^display_news_cat/([\d]+)/([\d]+)$ display_news_cat.php?news_cat=$1&p=$2
Afaik, this is normally accomplished with Apache .htaccess file rewrite rules.
Is you case this would look something like:
RewriteEngine on
RewriteRule ^display_news_cat/([0-9]+)/([0-9]+)$ display_news_cat.php?news_cat_id=$1&p=$2
If this doesn't work, try checking your access logs to see what's happening.
there are different ways to archive this, and it takes only 1 minute to find this out yourself using google. you could:
use an .htacces file with rewrite-rules to let the apache do the rewriting
map everything on localhost/ to an index.php, read and parse the request-string "by hand" hand show the correct site
Also you can hold it in one script use GET to retrieve the values you wish and re-create the URL with that values. I don't know if it will help you..
Anyway a .httacess file will be much more useful for you.
In the httpd.conf file I have AllowOverride FileInfo. In the .htaccess file in top level of my webserver with all the other files, I have this:
RewriteEngine On
RewriteRule ^downloads/?$ index.php?page=downloads [L,NC]
But it doesn't work. mywebsite/downloads and mywebsite/downloads/ always give a 404 not found. Any idea why? Thanks. (mywebsite/index.php?page=downloads does work).
And I'm restarting apache every time I change it.
And when I put the code above in httpd.conf, the website won't even load at all, just blank, spinning safari wheel forever.
Its fine if I just do RewriteEngine On, but if I do anything else (RewriteBase, RewriteRule), the web browser spend ages trying to load and finally giving this error:
Safari can’t open the page “http://mk12.gotdns.com/” because the server where this page is located isn’t responding.
Anyone have any idea what's wrong?
EDIT: I'm able to make, for example, css files forbidden with rewrite, and it works, but any rule that goes from downloads to index.php?page=downloads makes the server not respond (see above), it doesn't matter what page, the website won't load at all. Any ideas..?
The best way to debug rewrite rules is to enable rewrite logging so you can see what's going wrong.
It Worked!! I was putting the code in the wrong spot. It was in httpd.conf, but at the end. Move it into <Directory> and its good. Thanks for your help!
EDIT: Also, I found that It won't work if the flags are like this: [L, NC]. It has to be [L,NC] (no spaces).
So the two problems where that it wasn't inside <Directory "/Library/WebServer/Documents">, and there were spaces between the flags. Hopefully this will help someone else in the future.
Have you tired adding a slash in front of the "download" like below
RewriteRule ^/downloads/?$ index.php?page=downloads
EDIT: Try the code below:
RewriteEngine On
RewriteBase /
RewriteRule ^downloads/?$ /index.php?page=downloads
I would try removing the trailing slash and question mark after downloads, and the leading slash before index.php.
RewriteEngine On
RewriteBase /
RewriteRule ^downloads$ index.php?page=downloads.