I used to have php site with some keywords in file name like this
domain.com/?keyword-one,23
domain.com/?another-keyword,43
domain.com/?one-more-keyword,23
and so on
the problem is that I have an index.html file now and the above pages are still works because of that ? after the first / because the server is attaching those files as domain.com/index.html?keyword-one,23
is there any way to show error 410 gone using htaccess?
I used RewriteRule ^index.html$ - [R=404,L,NC] and it is not working.
Nevermind, I got it to work.
RewriteRule ^/?$ - [R=410,L,NC]
Related
On my website I have files index.php,home.php,about.php
And The full url is
http://example.com/about.php
and the wired thing is that
http://example.com/about.php#foobar
also goes to the about page . I want to block anything after my files name and redirect it to 404.
I copied this from a similar post :
Rewriterule ([a-zA-Z]+).([a-zA-Z]+) - [L]
Rewriterule ([a-zA-Z]+).([a-zA-Z]+) - [R=404,L]
Its not working. can you help me please?
Edit: its not a hashmark related question.
I want to redirect 404 a url with a trailing path.
I think you are looking for this :
AcceptPathInfo Off
Source : http://httpd.apache.org/docs/2.2/mod/core.html#AcceptPathInfo
I have a LAMP server configured with DocumentRoot /var/www changed to VirtualDocumentRoot /var/www/%-3/ in the Apache2 config file - this allows me to automatically map /var/www/<subdomain> to <subdomain>.example.com.
I'm currently in the process of learning CakePHP (2.x), with Cake in directory /var/www/foo/; I've noticed that the URLS aren't redirecting properly, and am attempting to resolve this issue; as per http://bit.ly/KmEhHl, I've modified the default .htaccess file to (among other things):
RewriteBase /cake
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
But this raises a 500 Internal Server Error - checking Apache2's error.log and rewrite.log, this is because .htaccess is causing an infinite redirect, and is appending app/webroot to the URI.
From my understanding, the L flag here should indicate 'last rule' - I'm assuming that this error is due to my poor understanding of mod_rewrite, but I'm not sure exactly where this is happening. Would the error be because of some other latent issue with this setup? I'm aware that there have been several questions on this already, and will update if any new information can be found on my end. Any help would be greatly appreciated!
Found an answer!
Full answer courtesy of user 'kostasz' at http://bit.ly/NSDWE2 in comments.
The hint was indeed the infinite redirect - using RewriteBase /cake was not the correct base URL.
To fix this issue, add RewriteBase / to each of the .htaccess files in /, /app/, and /app/webroot/.
I'm trying to get IIRF working so that it rewrites certain URLs, but ignores files like .css and .js files.
I have URLs like:
/admin/
/admin/user/
/admin/user/view-details/1
/admin/user/view-details/1?edit
Which all work, but I can't seem to get this to work:
/admin/_assets/css/admin.css
My .ini file looks like this:
RewriteRule /admin/([^/]+)/([^/]+)/([^/]+)\?edit$ /admin/index.php?edit&action=$1&sub-action=$2&id=$3 [L,I,QSA]
RewriteRule /admin/([^/]+)/([^/]+)/([^/]+)$ /admin/index.php?edit&action=$1&sub-action=$2&id=$3 [L,I,QSA]
RewriteRule /admin/([^/]+)/$ /admin/index.php?action=$1 [L,I,QSA]
RewriteRule ^/admin/(.*)$ - [L]
I've also tried:
RewriteRule (.+\.)(php|jpg|png|jpeg|gif|ttf|sql|txt|htm|zip|css)$ - [L]
The things I've tried give either a blank document when I navigate directly to the css file, or I get:
HTTP Error 404.4 - Not Found
The resource you are looking for does not have a handler associated with it.
I don't have much experience with IIRF or IIS, so I'm a bit stuck with what to try next. Am I looking in the wrong place? Or have I made a really basic mistake?
Thanks
Tip for debugging iirf: use StatusUrl to check first for problems.
I've managed to fix this by adding:
RewriteRule /admin/_assets/(.+)$ /admin/_assets/$1 [L,I,QSA]
to the top of my file. I'm still not sure why nothing is being logged, but this fixed it for my needs.
EDIT
After a comment from Seth below, and heading to a helpful apache page here, I have found that VirtualHosts are the way to go for the following issue.
/edit
--ORIGINAL POST--
First, a little background on file setup. I am running a LAMP server that hosts multiple domains. I have staging and live sites on this server, under different directories under the web root.
examples
/webroot/live/site1/[public files]
/webroot/live/site2/[public files]
/webroot/stage/site1/[public files]
/webroot/stage/site2/[public files]
The domains for each of these go to the IP of the server, which points at the webroot directory. I have an .htaccess file there to load the appropriate content based on the http_host.
examples
RewriteCond %{HTTP_HOST} ^www.site1-live.com [NC]
RewriteRule ^(.*)$ /live/site1/$1 [PT,L,QSA]
RewriteCond %{HTTP_HOST} ^www.site1-stage.com [NC]
RewriteRule ^(.*)$ /stage/site1/$1 [PT,L,QSA]
These work great for hitting the home page and any of the internal pages, even with the specific pages being like site1-live.com/view/123. Each site's htaccess handles those.
My issue (sorry it took so long to get here):
When I head to any subdirectory within a site, like www.site1-live.com/rss, the content loads just fine, but the URL changes to something like the following
http://www.site1-live.com/live/site1/rss/
Essentially showing the path from the webroot to the files.
How can I avoid this? I obviously want the url to remain www.site1-live.com/rss. Do I need an htaccess file inside the rss directory to block this somehow?
Thanks in advance!
replace ^www with ^(.*)
then have the whole url in the second line www.yourdomain.com/live/...
Doug,
why do you need the QSA flag?
Anyway, what is happening to you is that mod_index (or whatever is serving you directories) is redirecting you www.site1-live.com/rss (without the ending /) to the equivalent URL with the ending /.
If you don't use mod_alias or something list that on the rewritten URLs, removing the PT should work as you expect.
I just moved my website (asp.net) to the live environment. I realized they are running IIS 6 so all my nice and clean url rewriting doesn't work anymore. I was trying to implement URL rewriting using the .htaccess file.
I want to rewrite:
www.amicobio.co.uk/Menu.aspx to www.amicobio.co.uk/Food-Menu
So in .htaccess I set:
CaseInsensitive On
Options +FollowSymlinks
RewriteEngine On
RewriteRule ^Food-Menu$ Menu.aspx
But it doesn't work it says:
The requested URL
/a/m/amicobio.co.uk/public/Menu.aspx
was not found on this server.
Obviously the path is wrong but what is /a/m/ and how do I fix it? All the files in amicobio.co.uk/public/
Thanks.
I found the solution
it was
RewriteRule ^Food-Menu /Menu.aspx
in stead of
RewriteRule ^Food-Menu$ Menu.aspx