Search code examples
phpapachehttp-redirectnoscript

Redirect if no JavaScript


Here's my situation:

I'm trying to redirect users with JavaScript disabled to a PHP generated page (instead of an AJAX generated page) on my Apache server.

I'm currently using:

<noscript> <meta http-equiv="refresh" content="0; url=http://mydomain/no_js.php"> </noscript>

Is there a way to redirect users BEFORE the page loads?

P.S.: If not then any way faster than the one I'm currently using?

Thanks in advance!


Solution

  • If you need to redirect, make the PHP version the default and redirect if javascript is enabled. I would avoid this though and not have a redirect at all and just display on the same page based on whether javascript is enabled/disabled. You can show the javascript items if enabled. I usually have a class name no-script in the body of the page and remove it if javascript is enabled, you can then use CSS to target what to display based on that one tag.