Forum Moderators: phranque
How to make all url www.domainname.com/design/filename.html become www.domainname.com/filename.html ?
is it possible to use .htaccess? please show me the htaccess code and please help me
Thanks
Here are the two steps you must take:
1) Change all the links on all of your pages to link to /filename.htm instead of /design/filename.html
2) Move all files from the /design folder into the document root directory (home page folder) of your server,
- OR -
2) Add server-side code to internally rewrite all requests for .html pagees in the document root to the files in the /design subfolder.
Note that the second option for step two will not work unless there are no other .html files in the document root, or unless you provide an explicit list of all .html-page URLs that should be rewritten, or provide an explicit list of all .html-page URLs which should not be rewritten.
The links on your pages *define* the URL used on the Web; No server-side code can re-define those URLs. It is only possible to redirect them. But a redirect will not 'fix' the problem, since clients will continue to request those pages using the URLs found in links on your pages, the server will have to redirect these URLs every time they are requested, users will suffer the delay of these redirects every time they click a link, and every page request received by your server will have to be handled twice: once to redirect the old URL request, and a second time to serve the page when the correct URL is received.
This also means that your server access log and 'Web stats' files will be bloated and inaccurate, since two requests will be logged for every .html page actually served.
There is an optional third step which can be done after the first two steps are completed and tested. We can discuss that later.
Note that this is a discussion forum; We do not write code here, but instead help those who have already written code and need help getting it working properly. Our Apache Forum Charter and the Apache Server section of the WebmasterWorld library may be helpful to you.
Jim