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]
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 12 months ago.
Improve this question
I want to change url used in href from .htaccess. As I am working in a existing project so I don't want to change the href from 46 files. Is there any way? For instance the code below is in the html file.
<link href="http://localhost/example.com/UK/styles/style.css">
I want to change it to http://localhost/example.com/styles/style.css from .htaccess
Here, my absolute domain is http://localhost/example.com
And my .htaccess is in the document root
.htaccess doesn't actually "change url used in href", but it allows you to internally rewrite a request from /example.com/UK/styles/styles.css to /example.com/styles/styles.css. The user still sees /UK in the URL, the URL is unchanged, but the file that receives the request is.
For example, at the top of the .htaccess file in the "document root". (ie. at http://localhost/.htaccess) you can do something like the following:
RewriteEngine On
RewriteRule ^(example\.com)/UK/(styles/style.css)$ $1/$2 [L]
For a more general "any URL" solution:
RewriteRule ^(example\.com)/UK/(.*) $1/$2 [L]
$1 and $2 are backreferences to the captured subpatterns in the preceding RewriteRule pattern.
Reference:
https://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewriterule
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
Currently I placed my project in /www directory of my Apache2 server, and I can access this project by localhost/abc
However I want localhost to map to this project, what should I do in order to make localhost to map to my project?
You could try this in /etc/apache2/httpd.conf or similar (it's specific to your OS/distro). I don't run Apache locally, so not sure if something like this could work.
<VirtualHost ip:port>
ServerName localhost
DocumentRoot /www/your_project
</VirtualHost>
If you don't have access to httpd.conf you could put this into the .htaccess file:
RewriteEngine on
RewriteRule ^/$ /abc/
http://httpd.apache.org/docs/current/rewrite/remapping.html
Good Luck!
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.
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 wrote this lines in my .htaccess file:
<Directory /img>
Header set Cache-Control "max-age=604800, public"
</Directory>
But the server encountered an 500 Internal Server Error.
I really want to apply that rule to few directories (like: img/ js/ icons/ ),
but not to all of the image files in the site.
The question:
What is the right way to apply a rule to whole directory ?
Is it possible by single htacess file, without htacess file in each directory ?
You can't use a <Directory> block inside an htaccess file (which is essentially a <directory> itself). If you want to have requests for /img set a cache-control header, then put:
Header set Cache-Control "max-age=604800, public"
in the htaccess file in the /img directory.