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.
Related
I am helping someone move their WordPress site from a (truly) wretched Dotster shared plan to a VPS.
Everything is transferred and working, except Apache is only serving physical files like index.php and wp-admin/, etc... Other directories on the site will return a 404 error.
I am guessing this has to do with Apache ModRewrite, but I am truly unsure at this point.
Halp!
It looks really like a problem with rewriting.
Make sure you copied your .htaccess files
Make sure Apache mod_rewrite is enabled (for example by running a2enmod rewrite under debian)
Make sure overrided by .htaccess are enabled (AllowOverride All directive in Apache Configuration)
Overrides will make Apache look in .htaccess files. See http://httpd.apache.org/docs/2.2/mod/core.html#allowoverride
Hope it helps!
I have a problem trying to hide .php extension from the url
I have been asked to hide it and because they are on a shared host i don't think i have access to .htacess so is there another way to hide it through a php function that i would call everytime an anchor is being selected?
Is this truly about hiding .php or is it more about having cleaner URLs?
If you truly can't access .htaccess (i.e. your host has this turned off via AllowOverride None) and assuming you also can't have your Apache conf settings updated for your VHost, the best you can do may be
http://example.com/page.php/my/clean/url
By default, Apache will send this URL to page.php even with everything else after it. This is the most common way of creating "cleaner" URLs without access to mod_rewrite.
.htaccess is what you would have access to on a shared server, as opposed to httpd.conf, which you wouldn't.
Put a .htaccess file in your document root with the following
FAIL
If your site stops loading, then you can use .htaccess :)
Of course, ^ that is a joke.
I am having what I believe is a strange problem. I have several sites developed on the same hosting platform. All site seem to be fine except for one of them. The website is set up around 1 page (index.php) that retrieves the correct data to display from the database based on the path_info - this has worked for years - now on one site this has stopped working. By stopped working I mean it the page below now goes to a 404 error - I was under the impress that it should see the index.php as the script to use.
I believe this is an issue with htconfig or another file I don't have access to being misconfigured on the host's end. Perhaps someone can shed light on where I might direct them. My own htaccess file is completely empty:
wwww.testsite.com/index.php/page1
The above used to go to index.php and then using $_SERVER path_info retrieve page1 and get the contents associated with page1 from the database and display that on the page. Can someone confirm I am not going mad - that the above should go to index.php please? and perhaps too explain why the url is now seen as non-existent since it doesn't seem to be going to index.php but to page1. Thanks in advance for any advice.
Can someone confirm I am not going mad - that the above [wwww.testsite.com/index.php/page1] should go to index.php please?
Nope. That should look for a file called page1 in the directory index.php in the document root for www.testsite.com.
I think you used to have an .htaccess file that looked something like this:
RewriteEngine on
RewriteRule ^index.php(.*)$ index.php
Another possibility is that MultiViews were previously enabled and now not anymore. With MultiViews you also get the behavior you described. If it's allowed by the hoster, you can enable it by simply creating an .htaccess file containing:
Options MultiViews
If you put an .htaccess file with either one of abovementioned solutions in it in your document root, you can verify this.
In Apache, if you have AcceptPathInfo on anywhere relevant in the Apache config (including in .htaccess, if the server config allows it) and there's a file /index.php, then /index.php/stuff should indeed go to /index.php, and should set $_SERVER['PATH_INFO'] to "/stuff". The CGI script handler and mod_php* even do this by default, so it should just work unless it's explicitly turned off.
Either way, if it's currently off, you can turn it back on by adding AcceptPathInfo on to your .htaccess file, if AllowOverride FileInfo is set for the site.
I make no promises about other web servers, but PATH_INFO is part of the CGI spec, so i'd think most servers would have a similar setting.
Just very quick question about php.ini file. I created my own on my php.ini file and it works fine if I put it inside my 'public_html' directory. However the problem is it can obviously be viewed in browser through HTTP requests.
So, I am trying to move it outside my 'public_html' directory however it does not seem to work when outside my 'public_html'.
I know I could perhaps set in my .htaccess the following to avoid it being read:
<Files php.ini>
Order allow,deny
Deny from all
</Files>
However I do not want to do this as my php.ini can still get cached by Google if it's in the 'public_html' directory. Is there any suggestions to make it work outside my public_html?
I am running an Apache server. Thanks for any suggestions
You can use the PHPRC environment variable...see the documentation:
http://www.php.net/manual/en/configuration.file.php
It can't get cached by google if you block like that in .htaccess
Two suggestions:
Ensure that Apache can find your php.ini (PHPINIDIR /path/where/php.ini/is/located)
Ensure the file is readable by the webserver user.
How is it that you php.ini came to be in a web server accessible folder? It is the first time I hear of such a situation.
I thought hard on how you managed to do this, and the only answer I came up with is that you created a vhost in php folder. If that is the case, create another vhost out of the php.ini path, and remove the offending vhost. See this post for examples.
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.