.htaccess issue with modernizr (Unexpected token <) - .htaccess

I'm having issues with Modernizr throwing an 'Uncaught SyntaxError: Unexpected token <'
When I click the error in Chrome dev tools it reports the error as being on the first line at .
After some debugging I think I've narrowed the issue down weirdly to htaccess rewrites I have going on.
Here's what I have in my htaccess:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^faqs/ ./faqs.php
If I visit /faqs/I get the error. If I visit just /faqs.php there is no error. That's how I'm coming to the conclusion that the issue lies in this rewrite.
Has anyone seen anything like this before? Any ideas on a fix?
Cheers

Related

Using htaccess to rewrite a get variable

I've been trying to figure this out for a few hours but stumped. I am trying to rewrite the url with a get variable to make it seem like a file. I've tried many different answers I've seen to no avail. Is it possible that I don't have a certain setting turned on? Your help is greatly appreciated!!
I am trying to redirect
www.site.com/products/?q=coconut
to
www.site.com/products/coconut
so far this code gives me a 500 error
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /products?q=$1 [L,R=301]
Wow dumb mistake on my part, but leaving this up just in case someone else is pulling their hair out. I had a faulty php code which lead to a 500 error.

Redirect all 404 errors with 301 to index/homepage with htaccess

I know there are a few answers in the web, but none of them worked for me. For example I tried this, but ends up in 403 error for every page.
For your information I am hosting on domainfactory and I asked them, but they do not offer help for it. So I am not sure, if its not working out of this specific hoster, or this code is just not working.
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . / [L,R=301]
I know its not always best to redirect all to homepage, but in my case it is. So I am looking to redirect all 404 to my homepage.

not found error in webmaster when redirection handled through .htaccess

I am trying to find answer for this for a long time.
I have created one site and i handle the not found page(404 pages) through .htaccess.
Everything works great but when i submitted to google webmaster for indexing (in fetch as google) it showing an error ( status = not found).
Does anyone know How to tell google to handle these pages (index these pages)
my .htaccess file is
ERRORDOCUMENT 404 /redirect.php
in my redirect.php file i take the necessary action.
like if URL is www.mysite.com/username then profile of that user is shown
Thank in advance
Google will never index 404 error pages.
You can use .htaccess with:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ /redirect.php [L]
which redirected all links to pages that do not exist
if you use:
RewriteRule ^ /redirect.php [R=301,L]
the link change in the browser. But with [L] you can show your page without link change.

Getting Error 500 when trying to use RewriteRule

I am trying to figure out the code to make all my links with no extension to be redirected to a certain page using .htaccess. For example:
http://mysite.com/link
Gets rewritten to:
http://mysite.com/run.php?id=link
I have tried the following code but I receive an Internal Error 500 and can't even access my homepage.
RewriteEngine On
RewriteRule ^([^/]*)$ /run.php?id=$1 [L]
Thanks for your help I think found the answer:
RewriteEngine on
RewriteBase /
RewriteRule ^.htaccess$ - [F]
RewriteRule ^([A-z,0-9,_,-]+)/?$ /run.php?id=$1 [QSA]
This seems to work. Although I'm not soo sure if anything else is affected. The homepage still loads if I type www.mysite.com/index.php so I think it is ok.

Redirect russian URL in htaccess doesn't work

I'm changing my URL structure in my Wordpress website. So I'm using the .htaccess file to redirect the URLS. When I add the following code in .htaccess the url www.mydomain.com/test/?lang=en redirects correctly to www.test.com
RewriteEngine On
RewriteCond %{QUERY_STRING} ^lang=en$ [NC]
RewriteRule ^test/$ http://www.test.com/? [R=301,NE,NC,L]
My website is also in Russian.
My goal is to redirect www.mydomain.com/шарон/?lang=RU to www.test.com.
I tried to add the following code to .htaccess:
RewriteCond %{QUERY_STRING} ^lang=RU$ [NC]
RewriteRule ^%D1%88%D0%B0%D1%80%D0%BE%D0%BD/$ /www.test.com? [R=301,NE,NC,L]
But the redirect doesn't work. I got a "can't display the page" error, I think a 404 error.
I also tried to add the Russian text into the .htaccess file. And saved the .htaccess to UTF-8 file format.
RewriteCond %{QUERY_STRING} ^lang=RU$ [NC]
RewriteRule ^шарон/$ /www.test.com? [R=301,NE,NC,L]
Then I get the message below, my website isn't reachable anymore.
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator to inform of the time the error occurred and of anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
Does anyone have an idea how to redirect my Russian urls?
I'm not sure if URL can be specified that way when doing rewrites. Try changing it to
RewriteCond %{QUERY_STRING} ^lang=RU$ [NC]
RewriteRule ^\xd1\x88\xd0\xb0\xd1\x80\xd0\xbe\xd0\xbd/$ /www.test.com? [R=301,NE,NC,L]
Where
\xd1\x88\xd0\xb0\xd1\x80\xd0\xbe\xd0\xbd
equals to
%D1%88%D0%B0%D1%80%D0%BE%D0%BD
and therefore also to
шарон
Hope it helps. Comment on this if you have further problems. ;)

Resources