Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
as of title, I'm having problems with my .htaccess file, everything should be set fine, but has I write something as basic as
RewriteEngine on
it starts giving me that nice 500 Internal Server Error. I'm hosting on localhost on an Apache server (UNIX)
Obviously I triple checked that everything is set fine, and top of all that mod_rewrite is loaded.
Thanks for your precious help!
If the error occurs for every single type of instruction you put in the file (that is, caching, FilesMatch, ErrorDocument, etc), there are two possible options that I can think of right now:
The encoding of your .htaccess file is not compatible with the server you're running. Try converting it to ANSI, and then try again (Apache does not support Byte Order Marks, so you'd need to save it to ANSI, or UTF-8, without the BOM). If that does not work:
AllowOverride is not set correctly, or not at all. If you have access to the Virtual Host/Directory configuration, you'll need to enable it by adding the line AllowOverride All in the <Directory> container.
When you try to remove the code RewriteEngine on and the URL remapping or the URL redirecting is still functioning well, then you do not have to put that code in your .htaccess file, for your HTTP server was already configured that the rewrite engine is on. But if you've tried to remove it and the rewriting or the redirecting stop, then you must include all your .htaccess codes in your question. Then if it's empty, then why you need to turn the RewriteEngine on if you're not going to apply even a single RewriteRule?
Have you ever tried this:
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^notexist.html$ /index.html
And try to visit yourdomain.com/notexist.html if it's URL remapping into /index.html.
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
Improve this question
I have a client who is moving away from an NGINX webserver to Apache. Everything is simple nothing complicated however since I'm an NGINX kinda guy I forgot how to convert the NGINX rewrite rules onto apache ones.
For example, these are the NGINX rewrites
rewrite ^/Tower-Topics-Calendar/?$ https://$host/events/ permanent;
How would I convert something like that onto .htaccess to use with Apache?
rewrite ^/Tower-Topics-Calendar/?$ https://$host/events/ permanent;
This looks like an external 301 redirect from /Tower-Topics-Calendar (with and without a trailing slash) to https://<host>/events/ - where <host> is the same hostname from the request and you specifically state the HTTPS protocol in the target.
In .htaccess you can achieve this using mod_rewrite. For example:
RewriteEngine On
RewriteRule ^Tower-Topics-Calendar/?$ https://%{HTTP_HOST}/events/ [R=301,L]
Note the absence of the slash prefix in the RewriteRule pattern.
However, if you don't specifically need to include the HTTPS scheme (ie. this is already canonicalised) then you can use a single mod_alias RedirectMatch directive instead. For example:
RedirectMatch 301 ^Tower-Topics-Calendar/?$ /events/
OR, to include the HTTPS protocol, you need to hardcode the hostname:
RedirectMatch 301 ^Tower-Topics-Calendar/?$ https://example.com/events/
This question already has answers here:
Do you have to restart apache to make re-write rules in the .htaccess take effect?
(7 answers)
Closed 7 years ago.
I am trying to debug some .htaccess problems on Apache but I am new to mod_rewrite.c. I would like to know whether I need to restart Apache in XAMPP whenever I make modifications to the .htaccess files, or whether these are parsed and applied whenever a web page is served independently of whether Apache is restarted.
A restart is not required for changes to .htaccess. Something else is wrong.
Make sure your .htaccess includes the statement
RewriteEngine on
which is required even if it's also present in httpd.conf. Also check that .htaccess is readable by the httpd process.
Check the error_log - it will tell you of any errors in .htaccess if it's being used.
Putting an intentional syntax error in .htaccess is a good check to make sure the file is being used -- you should get a 500 error on any page in the same directory.
Lastly, you can enable a rewrite log using commands like the following in your httpd.conf:
RewriteLog "logs/rewritelog"
RewriteLogLevel 7
The log file thus generated will give you the gory detail of which rewrite rules matched and how they were handled.
Do you have to restart apache to make re-write rules in the .htaccess take effect?
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
Like the title says I want to visit my webpage without typing .html after the webadres.
So for example I have to type this at the moment: www.webadres.com/webpage.html
Now I want to change that into www.webadres.com/webpage
I've already tried some things like deleting the .html extension on the end of my file but that (of course) doesn't work.
I see I missed something:
I don't really understand it but I got a folder (called "cgi-bin") with a .htacces file.
In the .htacces file is the following text:
Options -Indexes +ExecCGI AddHandler cgi-script .cgi .pl
I want a webpage like this
www.example.com/webpage
Instead of
www.example.com/webpage.html
I didn't know about all the server side technologies but now it seems I have Apache.
If it didn't worked out you could also check out these:
How to remove .html from URL
ReWrite rule to add .html extension
create a htaccess file which has the name of .htaccess, then place the following code
RewriteEngine on
RewriteRule ^yourPage$ yourPage.html [NC,L]
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I have many url links in /abc/ sub-directory, like
http://www.domain.com/abc/products-12345
http://www.domain.com/abc/products-23456
http://www.domain.com/abc/products-34567
http://www.domain.com/abc/new-items
Now I want to url rewrite /abc/products- to /def/products-
http://www.domain.com/def/products-12345
http://www.domain.com/def/products-23456
http://www.domain.com/def/products-34567
http://www.domain.com/abc/new-items
My code in .htaccess, but nothing changed. How to rewrite in this case? Thanks.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^abc/products-(.*)$ /def/products-$1 [L,R=301]
</IfModule>
As you can test on this simulator the rules should work.
The most probable problem you are facing should be:
The global configuration does not allow for .htaccess overwrite
.htaccess is not readable for apache user
You have no mod_rewrite active on this apache server, thus no trigger to <IfModule> directive.
Best troubleshooting option would be trying a redirection of all page to a static page. If this does not work, look for a configuration problem.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I have enabled mod proxy to serve my jsp and servlets and it seem to work fine. So if i hit localhost, it takes request to tomcat and executes it. What is want is that servlets and jsp are forwarded to tomcat while php is handled by apache. Both JSP/Servlets and PHP files are in the same folder and I need to make a call from JSP?Servlet to PHP or may be vice versa as well. Now the problem is that PHP is also forwarded to tomcat it seems if I use following pattern -
ProxyPass /auto http://serv.corp.com:8080/auto/
All JSP/Servlets and PHP files are inside auto folder which is in webapps folder.
Kindly help me to route static content i.e. PHP to apache.
To server static content by Apache and remain files by appserver (jboss in my case)..
httpd.conf of Apache should look as:--
DocumentRoot /usr/local/apache2/htdocs
ProxyPass / !
ProxyPass / https://www.example.com:8443/
ProxyPassReverse / https://www.example.com:8443/
here for example /logo.gif will be served directly by
Apache from the /usr/local/apache2/htdocs/logo.gif file.
And everything else will be served by appserver.
Hope it will be useful
You want to use ProxyPassMatch rather than ProxyPass. Something like (untested)
ProxyPassMatch ^/(.*\.php)$ !