{"id":246438,"date":"2025-10-08T11:23:19","date_gmt":"2025-10-08T11:23:19","guid":{"rendered":"https:\/\/www.bluehost.com\/blog\/?p=246438"},"modified":"2025-10-08T11:23:22","modified_gmt":"2025-10-08T11:23:22","slug":"redirects-that-do-not-work-due-to-php-variables","status":"publish","type":"post","link":"https:\/\/www.bluehost.com\/blog\/redirects-that-do-not-work-due-to-php-variables\/","title":{"rendered":"How to Fix Issues with PHP Redirects"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\" id=\"h-problem\">Problem<\/h2>\n\n\n\n<p>The&nbsp;<a href=\"https:\/\/www.bluehost.com\/blog\/the-ultimate-guide-to-wordpress-url-redirection-and-bluehost-redirects\/\" target=\"_blank\" rel=\"noreferrer noopener\">redirection<\/a>&nbsp;of&nbsp;<strong>www.yourdomain.ext\/default.html<\/strong>&nbsp;or<em>&nbsp;<\/em><strong>index.html to http:\/\/www.yourdomain.ext\/index.php?act=whatever<\/strong>&nbsp;redirects it to&nbsp;<strong>http:\/\/www.yourdomain.ext\/index.php%3fact=whatever<\/strong>. In other words, why is &#8220;?&#8221; replaced with &#8220;%3f&#8221; (or anything else) in the address line? Why is your php redirect not working?<\/p>\n\n\n\n<p>The solution below will show how to fix PHP redirect issues using Apache&#8217;s&nbsp;<a href=\"http:\/\/httpd.apache.org\/docs\/2.4\/mod\/mod_rewrite.html\" target=\"_blank\" rel=\"noreferrer noopener\">mod_rewrite module<\/a>. The mod_rewrite module is a tool that allows you to manipulate URLs using an unlimited number of rules. You can attach an unlimited number of rule conditions to each rule. This allows you to rewrite URLs by considering server variables, HTTP headers, environment variables, or time stamps.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-solution\">Solution<\/h2>\n\n\n\n<p>To fix the php redirect problem, you can use the&nbsp;<a href=\"https:\/\/httpd.apache.org\/docs\/2.4\/mod\/mod_rewrite.html\" target=\"_blank\" rel=\"noreferrer noopener\">mod_rewrite module<\/a>&nbsp;to redirect a URL to another URL, transform long URLs into short ones, redirect missing pages, and more.<\/p>\n\n\n\n<p>Begin rewriting:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># time to get dynamic, see..\nrewriterule ^(.*).html $1.php<\/code><\/pre>\n\n\n\n<p>Whenever you use mod_rewrite, you need only to do this once per&nbsp;<a href=\"https:\/\/www.bluehost.com\/help\/article\/htaccess-tutorial\" target=\"_blank\" rel=\"noreferrer noopener\">.htaccess file<\/a>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Options +SymlinksIfOwnerMatches\nRewriteEngine on<\/code><\/pre>\n\n\n\n<p>Before any ReWrite rules,&nbsp;<strong>+FollowSymLinks<\/strong>&nbsp;must be enabled for any rules to work. This is a security requirement of the rewrite engine. Usually, it is enabled in the root, and you should not have to add it.<\/p>\n\n\n\n<p>The following line switches on the rewrite engine for that folder. If this directive is in your main .htaccess file, then the ReWrite engine is theoretically enabled for your entire site. It is wise always to add that line before you write any redirections. While some of the directives on this page may appear split into two lines, in your .htaccess file, they must exist entirely on one line.<\/p>\n\n\n\n<p><strong>Note:<\/strong>&nbsp;For instructions on how to do a PHP header redirect and best practices for using php header redirects, check out the article:&nbsp;<a href=\"https:\/\/www.bluehost.com\/help\/article\/php-redirect\" target=\"_blank\" rel=\"noreferrer noopener\">How to Code a PHP Redirect &#8211; PHP Header Redirect<\/a>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-simple-rewriting\"><a><\/a>Simple Rewriting<\/h3>\n\n\n\n<p>Apache scans all incoming URL requests, checks for matches in your .htaccess file, and rewrites those matching URLs to whatever you specify. For example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#all requests to whatever.html will be sent to whatever.php:\nOptions +SymlinksIfOwnerMatches\nRewriteEngine on\nRewriteRule ^(.*).html $1.php &#91;nc]<\/code><\/pre>\n\n\n\n<p>This can be helpful for anyone updating a site from static HTML (you could use .html or .htm(.*)) to dynamic PHP pages, where requests to the old pages are automatically rewritten to your new URLs. Visitors and search engines can access your content either way. Moreover, this enables you to split PHP code and its included HTML structures into two separate files, making editing and updating easy. The [nc] part at the end means &#8220;No Case&#8221; or &#8220;case-insensitive&#8221;.<\/p>\n\n\n\n<p>Users can link to&nbsp;<strong>whatever.html<\/strong>&nbsp;or&nbsp;<strong>whatever.php<\/strong>, but they always get&nbsp;<strong>whatever.php<\/strong><em>&nbsp;<\/em>in their browser, which works even if&nbsp;<strong>whatever.html<\/strong>&nbsp;doesn&#8217;t exist.<\/p>\n\n\n\n<p>It can be tricky. Visitors will still have&nbsp;<strong>whatever.html<\/strong>&nbsp;in their browser address bar and will still keep bookmarking your old .html URLs. This is a php redirect loop. Search engines will also keep on indexing your links as&nbsp;<strong>.htm<\/strong>. Some have even argued that serving up the same content from two different places could have you penalized by search engines. This may or may not bother you, but if it does, mod_rewrite can help:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># this will do a \"real\" http redirection:\nOptions +SymlinksIfOwnerMatches\nrewriteengine on\nrewriterule ^(.+).htm$ http:\/\/yourdomain.ext\/$1.php &#91;r=301,nc]<\/code><\/pre>\n\n\n\n<p>This time, we instruct mod_rewrite to send a proper HTTP (permanently moved) redirection, also known as a 301 redirect. The user&#8217;s browser is physically redirected to a new URL, and&nbsp;<strong>whatever.php<\/strong>&nbsp;appears in their browser&#8217;s address bar, search engines and other entities will automatically update their links to the .php versions.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-complex-rewriting\"><a><\/a>Complex Rewriting<\/h3>\n\n\n\n<p>You may have noticed that the above examples use a regular expression to match variables. That means it matches the part inside (.+) and uses it to construct &#8220;$1&#8221; in the new URL. In other words, (.+) = $1, you could have multiple (.+) parts, and for each, mod_rewrite automatically creates a matching $1, $2, $3, etc., in your target URL. For example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># a more complex rewrite rule:\nOptions +SymlinksIfOwnerMatches\nRewriteEngine on\nRewriteRule ^files\/(.+)\/(.+).zip download.php?section=$1&amp;file=$2 &#91;nc]<\/code><\/pre>\n\n\n\n<p>This would allow you to present a link as:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>http:&#47;&#47;mysite\/files\/games\/hoopy.zip<\/code><\/pre>\n\n\n\n<p>and in the background, have that translated to:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>http:&#47;&#47;mysite\/download.php?section=games&amp;file=hoopy<\/code><\/pre>\n\n\n\n<p>which some scripts could process. Many search engines simply do not follow our&nbsp;<em>?generated=links<\/em>. So, if you create generating pages, this is useful. Google will handle a good few parameters in your URL without any problems. However, other search engines will not.<\/p>\n\n\n\n<p>Presenting links as\/standard\/paths means you&#8217;re less likely to get users making typos in typed URLs.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#an even more complex rewrite rule:\nOptions +SymlinksIfOwnerMatches\nRewriteEngine on\nRewriteRule ^blog\/(&#91;0-9]+)-(&#91;a-z]+) http:\/\/yourdomain.ext\/blog\/index.php?archive=$1-$2 &#91;nc]<\/code><\/pre>\n\n\n\n<p>Using the code above would enable anyone to access blog archives by doing:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>http:&#47;&#47;yourdomain.ext\/blog\/2003-nov<\/code><\/pre>\n\n\n\n<p>in their browser and have it automatically transformed server-side into:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>http:&#47;&#47;yourdomain.ext\/blog\/index.php?archive=2003-nov<\/code><\/pre>\n\n\n\n<p>which yourdomainblog would understand. It&#8217;s easy to see that you can perform some URL manipulations with a basic understanding of POSIX regular expression.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-shorten-urls\"><a><\/a>Shorten URLs<\/h3>\n\n\n\n<p>One common use of mod_rewrite is to shorten URLs. Shorter URLs are easier to remember and easier to type. For example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># beware the regular expression:\nOptions +SymlinksIfOwnerMatches\nRewriteEngine On\nRewriteRule ^grab(.*) \/public\/files\/download\/download.php$1<\/code><\/pre>\n\n\n\n<p>This rule would transform the user&#8217;s URL server-side:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>http:&#47;&#47;mysite\/grab?file=my.zip<\/code><\/pre>\n\n\n\n<p>into:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>http:&#47;&#47;mysite\/public\/files\/download\/download.php?file=my.zip<\/code><\/pre>\n\n\n\n<p>With this technique, you can move \/public\/files\/download\/ to anywhere else on your site, and all the old links still work fine. Just change your .htaccess file to reflect the new location. Edit one line, and you are done.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>http:\/\/yourdomain.ext\/img\/hotlink.png &#91;nc]<\/code><\/pre>\n\n\n\n<p>You may see the last line broken into two, but it&#8217;s all one line (all the directives on this page are). So, take a look at what it does.<\/p>\n\n\n\n<p>We begin by enabling the rewrite engine, as always.<\/p>\n\n\n\n<p>The first RewriteCond line allows direct requests (not from other pages &#8211; an &#8220;empty referrer&#8221;) to pass unmolested. The next line means if the browser did send a referrer header and the word &#8220;yourdomain&#8221; is not in the domain part of it, then DO rewrite this request.<\/p>\n\n\n\n<p>The final RewriteRule line instructs mod_rewrite to rewrite all matched requests (anything without &#8220;yourdomain&#8221; in its referrer), asking for gifs, jpegs, or pngs to an alternative image.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-httpd-conf\"><a><\/a>httpd.conf<\/h3>\n\n\n\n<p>Remember, if you put these rules in the main server conf file (usually httpd.conf) rather than a .htaccess file, you&#8217;ll need to use&nbsp;<strong>^\/&#8230; .<\/strong><strong>..<\/strong>&nbsp;instead of<strong>&nbsp;^&#8230; &#8230;&nbsp;<\/strong>at the beginning of the RewriteRule line, in other words, add a slash. But since httpd.conf is restricted to access, this does not apply at Bluehost.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-inheritance\"><a><\/a>Inheritance<\/h3>\n\n\n\n<p>If you are creating rules in the subfolders of your site, please read below.<\/p>\n\n\n\n<p>Note that rules in top folders apply to all the folders inside those folders. We call this &#8220;inheritance.&#8221; Usually, this works. However, if you start creating other rules inside subfolders, you will obliterate the rules already applying to that folder due to inheritance or descendency if you prefer just the ones applying to that subfolder. For example:<\/p>\n\n\n\n<p>Let&#8217;s say you have a rule in your main \/.htaccess that redirects requests for files ending&nbsp;<strong>.html&nbsp;<\/strong>to their&nbsp;<strong>.php&nbsp;<\/strong>equivalent, just like the example earlier. Now, if you need to add some rewrite rules to your \/osx\/.htaccess file, the&nbsp;<strong>.html&nbsp;<\/strong>&gt;&gt;&nbsp;<strong>.php<\/strong>&nbsp;redirection will no longer work for the \/osx\/ subfolder. You must reinsert it but with a crucial difference.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># this works fine, site-wide, in my main .htaccess file\n# main (top-level) .htaccess file..\n# requests to file.html goto file.php\nOptions +SymlinksIfOwnerMatches\nrewriteengine on\nrewriterule ^(.*).htm$ http:\/\/yourdomain.ext\/$1.php &#91;r=301,nc]<\/code><\/pre>\n\n\n\n<p>Below is the updated \/osx\/. htaccess file, with the<strong>&nbsp;.html<\/strong>&nbsp;&gt;&gt;&nbsp;<strong>.php<\/strong>&nbsp;redirection rule reinserted, but you will need to reinsert the rules for it to work in this subfolder:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># \/osx\/.htaccess file..\nOptions +SymlinksIfOwnerMatches\nrewriteengine on\nrewriterule some rule that I need here\nrewriterule some other rule I need here\nrewriterule ^(.*).htm$ http:\/\/yourdomain.ext\/osx\/$1.php &#91;r=301,nc]<\/code><\/pre>\n\n\n\n<p>Spot the difference in the subfolder rule. You must add the current path to the new rule. Now it works again. If you remember this, you can go replicating rewrite rules all everywhere.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-summary\"><a><\/a>Summary<\/h2>\n\n\n\n<p>Mod_rewrite allows you to send browsers from anywhere to anywhere. Moreover, you can create rules on the requested URL and on the IP address, browser agent (send old browsers to different pages, for instance), and even the time of day.<\/p>\n\n\n\n<p>The ins and outs of mod_rewrite syntax are topics for a much longer document than this. You can try more advanced rewriting rules. Please check out the&nbsp;<a href=\"https:\/\/httpd.apache.org\/docs\/2.4\/mod\/mod_rewrite.html\" target=\"_blank\" rel=\"noreferrer noopener\">Apache documentation<\/a>&nbsp;for more information. If you are running some *nix operating system (if you have Apache installed on any operating system), there will likely be a copy of the Apache manual on your machine. Check out these excellent mod_rewriting guides for syntax bits.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>http:&#47;&#47;www.ilovejackdaniels.com\/apache\/mod_rewrite-cheat-sheet\/\nhttp:\/\/httpd.apache.org\/docs\/1.3\/mod\/mod_rewrite.html\nhttp:\/\/httpd.apache.org\/docs\/1.3\/misc\/rewriteguide.html\nhttp:\/\/forum.modrewrite.com\/<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Problem The&nbsp;redirection&nbsp;of&nbsp;www.yourdomain.ext\/default.html&nbsp;or&nbsp;index.html to http:\/\/www.yourdomain.ext\/index.php?act=whatever&nbsp;redirects it to&nbsp;http:\/\/www.yourdomain.ext\/index.php%3fact=whatever. In other words, why is &#8220;?&#8221; replaced with &#8220;%3f&#8221; (or anything else) in the address line? Why is your php redirect not working? The solution below will show how to fix PHP redirect issues using Apache&#8217;s&nbsp;mod_rewrite module. The mod_rewrite module is a tool that allows you to manipulate URLs [&hellip;]<\/p>\n","protected":false},"author":138,"featured_media":240661,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_yoast_wpseo_title":"","_yoast_wpseo_metadesc":"","inline_featured_image":false,"footnotes":""},"categories":[3046],"tags":[],"ppma_author":[842],"class_list":["post-246438","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-development"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.1 (Yoast SEO v27.1.1) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>How to Fix Issues with PHP Redirects - Bluehost Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.bluehost.com\/blog\/wp-json\/wp\/v2\/posts\/246438\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Fix Issues with PHP Redirects\" \/>\n<meta property=\"og:description\" content=\"Problem The&nbsp;redirection&nbsp;of&nbsp;www.yourdomain.ext\/default.html&nbsp;or&nbsp;index.html to http:\/\/www.yourdomain.ext\/index.php?act=whatever&nbsp;redirects it to&nbsp;http:\/\/www.yourdomain.ext\/index.php%3fact=whatever. In other words, why is &#8220;?&#8221; replaced with &#8220;%3f&#8221; (or anything else) in the address line? Why is your php redirect not working? The solution below will show how to fix PHP redirect issues using Apache&#8217;s&nbsp;mod_rewrite module. The mod_rewrite module is a tool that allows you to manipulate URLs [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.bluehost.com\/blog\/redirects-that-do-not-work-due-to-php-variables\/\" \/>\n<meta property=\"og:site_name\" content=\"Bluehost Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/bluehost\/\" \/>\n<meta property=\"article:published_time\" content=\"2025-10-08T11:23:19+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-10-08T11:23:22+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.bluehost.com\/blog\/wp-content\/uploads\/2024\/01\/wondersuite-1.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1199\" \/>\n\t<meta property=\"og:image:height\" content=\"618\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Mohit Sharma\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@bluehost\" \/>\n<meta name=\"twitter:site\" content=\"@bluehost\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Mohit Sharma\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.bluehost.com\/blog\/redirects-that-do-not-work-due-to-php-variables\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.bluehost.com\/blog\/redirects-that-do-not-work-due-to-php-variables\/\"},\"author\":{\"name\":\"Mohit Sharma\",\"@id\":\"https:\/\/www.bluehost.com\/blog\/#\/schema\/person\/963ada146537ec6b6cc4d4f02e6c40c8\"},\"headline\":\"How to Fix Issues with PHP Redirects\",\"datePublished\":\"2025-10-08T11:23:19+00:00\",\"dateModified\":\"2025-10-08T11:23:22+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.bluehost.com\/blog\/redirects-that-do-not-work-due-to-php-variables\/\"},\"wordCount\":1363,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.bluehost.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.bluehost.com\/blog\/redirects-that-do-not-work-due-to-php-variables\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.bluehost.com\/blog\/wp-content\/uploads\/2025\/09\/default-bh.png\",\"articleSection\":[\"Development\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.bluehost.com\/blog\/redirects-that-do-not-work-due-to-php-variables\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.bluehost.com\/blog\/redirects-that-do-not-work-due-to-php-variables\/\",\"url\":\"https:\/\/www.bluehost.com\/blog\/redirects-that-do-not-work-due-to-php-variables\/\",\"name\":\"How to Fix Issues with PHP Redirects - Bluehost Blog\",\"isPartOf\":{\"@id\":\"https:\/\/www.bluehost.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.bluehost.com\/blog\/redirects-that-do-not-work-due-to-php-variables\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.bluehost.com\/blog\/redirects-that-do-not-work-due-to-php-variables\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.bluehost.com\/blog\/wp-content\/uploads\/2025\/09\/default-bh.png\",\"datePublished\":\"2025-10-08T11:23:19+00:00\",\"dateModified\":\"2025-10-08T11:23:22+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.bluehost.com\/blog\/redirects-that-do-not-work-due-to-php-variables\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.bluehost.com\/blog\/redirects-that-do-not-work-due-to-php-variables\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.bluehost.com\/blog\/redirects-that-do-not-work-due-to-php-variables\/#primaryimage\",\"url\":\"https:\/\/www.bluehost.com\/blog\/wp-content\/uploads\/2025\/09\/default-bh.png\",\"contentUrl\":\"https:\/\/www.bluehost.com\/blog\/wp-content\/uploads\/2025\/09\/default-bh.png\",\"width\":1200,\"height\":629},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.bluehost.com\/blog\/redirects-that-do-not-work-due-to-php-variables\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Blog\",\"item\":\"https:\/\/www.bluehost.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"WordPress\",\"item\":\"https:\/\/www.bluehost.com\/blog\/category\/wordpress\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Development\",\"item\":\"https:\/\/www.bluehost.com\/blog\/category\/wordpress\/development\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"How to Fix Issues with PHP Redirects\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.bluehost.com\/blog\/#website\",\"url\":\"https:\/\/www.bluehost.com\/blog\/\",\"name\":\"Bluehost\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/www.bluehost.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.bluehost.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.bluehost.com\/blog\/#organization\",\"name\":\"Bluehost\",\"url\":\"https:\/\/www.bluehost.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.bluehost.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.bluehost.com\/blog\/wp-content\/uploads\/2023\/08\/bluehost-logo.svg\",\"contentUrl\":\"https:\/\/www.bluehost.com\/blog\/wp-content\/uploads\/2023\/08\/bluehost-logo.svg\",\"width\":136,\"height\":24,\"caption\":\"Bluehost\"},\"image\":{\"@id\":\"https:\/\/www.bluehost.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/bluehost\/\",\"https:\/\/x.com\/bluehost\",\"https:\/\/www.linkedin.com\/company\/bluehost-com\/\",\"https:\/\/www.youtube.com\/user\/bluehost\",\"https:\/\/en.wikipedia.org\/wiki\/Bluehost\"],\"description\":\"Bluehost is a leading web hosting provider empowering millions of websites worldwide. \\u2028Discover how Bluehost's expertise, reliability, and innovation can help you achieve your online goals.\",\"telephone\":\"+1-888-401-4678\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.bluehost.com\/blog\/#\/schema\/person\/963ada146537ec6b6cc4d4f02e6c40c8\",\"name\":\"Mohit Sharma\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.bluehost.com\/blog\/#\/schema\/person\/image\/2db1a2f67f45c93b46c4cb340a8d96bc\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/ef26790cc4942b0fc60957ce3a9d0854c759a20994b106b99defa5385a80dcca?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/ef26790cc4942b0fc60957ce3a9d0854c759a20994b106b99defa5385a80dcca?s=96&d=mm&r=g\",\"caption\":\"Mohit Sharma\"},\"description\":\"I\u2019m Mohit Sharma, a content writer at Bluehost who focuses on WordPress. I enjoy making complex technical topics easy to understand. When I\u2019m not writing, I\u2019m usually gaming. With skills in HTML, CSS, and modern IT tools, I create clear and straightforward content that explains technical ideas.\",\"sameAs\":[\"https:\/\/www.linkedin.com\/in\/mohitsharma066\/\"],\"honorificPrefix\":\"Mr\",\"birthDate\":\"1996-10-06\",\"gender\":\"male\",\"knowsAbout\":[\"HTML\",\"WordPress\",\"Writing\"],\"knowsLanguage\":[\"English\",\"Hindi\"],\"jobTitle\":\"Web Content Writer\",\"worksFor\":\"Newfold Digital\",\"url\":\"https:\/\/www.bluehost.com\/blog\/author\/mohit-sharma\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"How to Fix Issues with PHP Redirects - Bluehost Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.bluehost.com\/blog\/wp-json\/wp\/v2\/posts\/246438\/","og_locale":"en_US","og_type":"article","og_title":"How to Fix Issues with PHP Redirects","og_description":"Problem The&nbsp;redirection&nbsp;of&nbsp;www.yourdomain.ext\/default.html&nbsp;or&nbsp;index.html to http:\/\/www.yourdomain.ext\/index.php?act=whatever&nbsp;redirects it to&nbsp;http:\/\/www.yourdomain.ext\/index.php%3fact=whatever. In other words, why is &#8220;?&#8221; replaced with &#8220;%3f&#8221; (or anything else) in the address line? Why is your php redirect not working? The solution below will show how to fix PHP redirect issues using Apache&#8217;s&nbsp;mod_rewrite module. The mod_rewrite module is a tool that allows you to manipulate URLs [&hellip;]","og_url":"https:\/\/www.bluehost.com\/blog\/redirects-that-do-not-work-due-to-php-variables\/","og_site_name":"Bluehost Blog","article_publisher":"https:\/\/www.facebook.com\/bluehost\/","article_published_time":"2025-10-08T11:23:19+00:00","article_modified_time":"2025-10-08T11:23:22+00:00","og_image":[{"width":1199,"height":618,"url":"https:\/\/www.bluehost.com\/blog\/wp-content\/uploads\/2024\/01\/wondersuite-1.png","type":"image\/png"}],"author":"Mohit Sharma","twitter_card":"summary_large_image","twitter_creator":"@bluehost","twitter_site":"@bluehost","twitter_misc":{"Written by":"Mohit Sharma","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.bluehost.com\/blog\/redirects-that-do-not-work-due-to-php-variables\/#article","isPartOf":{"@id":"https:\/\/www.bluehost.com\/blog\/redirects-that-do-not-work-due-to-php-variables\/"},"author":{"name":"Mohit Sharma","@id":"https:\/\/www.bluehost.com\/blog\/#\/schema\/person\/963ada146537ec6b6cc4d4f02e6c40c8"},"headline":"How to Fix Issues with PHP Redirects","datePublished":"2025-10-08T11:23:19+00:00","dateModified":"2025-10-08T11:23:22+00:00","mainEntityOfPage":{"@id":"https:\/\/www.bluehost.com\/blog\/redirects-that-do-not-work-due-to-php-variables\/"},"wordCount":1363,"commentCount":0,"publisher":{"@id":"https:\/\/www.bluehost.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.bluehost.com\/blog\/redirects-that-do-not-work-due-to-php-variables\/#primaryimage"},"thumbnailUrl":"https:\/\/www.bluehost.com\/blog\/wp-content\/uploads\/2025\/09\/default-bh.png","articleSection":["Development"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.bluehost.com\/blog\/redirects-that-do-not-work-due-to-php-variables\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.bluehost.com\/blog\/redirects-that-do-not-work-due-to-php-variables\/","url":"https:\/\/www.bluehost.com\/blog\/redirects-that-do-not-work-due-to-php-variables\/","name":"How to Fix Issues with PHP Redirects - Bluehost Blog","isPartOf":{"@id":"https:\/\/www.bluehost.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.bluehost.com\/blog\/redirects-that-do-not-work-due-to-php-variables\/#primaryimage"},"image":{"@id":"https:\/\/www.bluehost.com\/blog\/redirects-that-do-not-work-due-to-php-variables\/#primaryimage"},"thumbnailUrl":"https:\/\/www.bluehost.com\/blog\/wp-content\/uploads\/2025\/09\/default-bh.png","datePublished":"2025-10-08T11:23:19+00:00","dateModified":"2025-10-08T11:23:22+00:00","breadcrumb":{"@id":"https:\/\/www.bluehost.com\/blog\/redirects-that-do-not-work-due-to-php-variables\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.bluehost.com\/blog\/redirects-that-do-not-work-due-to-php-variables\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.bluehost.com\/blog\/redirects-that-do-not-work-due-to-php-variables\/#primaryimage","url":"https:\/\/www.bluehost.com\/blog\/wp-content\/uploads\/2025\/09\/default-bh.png","contentUrl":"https:\/\/www.bluehost.com\/blog\/wp-content\/uploads\/2025\/09\/default-bh.png","width":1200,"height":629},{"@type":"BreadcrumbList","@id":"https:\/\/www.bluehost.com\/blog\/redirects-that-do-not-work-due-to-php-variables\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog","item":"https:\/\/www.bluehost.com\/blog\/"},{"@type":"ListItem","position":2,"name":"WordPress","item":"https:\/\/www.bluehost.com\/blog\/category\/wordpress\/"},{"@type":"ListItem","position":3,"name":"Development","item":"https:\/\/www.bluehost.com\/blog\/category\/wordpress\/development\/"},{"@type":"ListItem","position":4,"name":"How to Fix Issues with PHP Redirects"}]},{"@type":"WebSite","@id":"https:\/\/www.bluehost.com\/blog\/#website","url":"https:\/\/www.bluehost.com\/blog\/","name":"Bluehost","description":"","publisher":{"@id":"https:\/\/www.bluehost.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.bluehost.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.bluehost.com\/blog\/#organization","name":"Bluehost","url":"https:\/\/www.bluehost.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.bluehost.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.bluehost.com\/blog\/wp-content\/uploads\/2023\/08\/bluehost-logo.svg","contentUrl":"https:\/\/www.bluehost.com\/blog\/wp-content\/uploads\/2023\/08\/bluehost-logo.svg","width":136,"height":24,"caption":"Bluehost"},"image":{"@id":"https:\/\/www.bluehost.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/bluehost\/","https:\/\/x.com\/bluehost","https:\/\/www.linkedin.com\/company\/bluehost-com\/","https:\/\/www.youtube.com\/user\/bluehost","https:\/\/en.wikipedia.org\/wiki\/Bluehost"],"description":"Bluehost is a leading web hosting provider empowering millions of websites worldwide. \u2028Discover how Bluehost's expertise, reliability, and innovation can help you achieve your online goals.","telephone":"+1-888-401-4678"},{"@type":"Person","@id":"https:\/\/www.bluehost.com\/blog\/#\/schema\/person\/963ada146537ec6b6cc4d4f02e6c40c8","name":"Mohit Sharma","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.bluehost.com\/blog\/#\/schema\/person\/image\/2db1a2f67f45c93b46c4cb340a8d96bc","url":"https:\/\/secure.gravatar.com\/avatar\/ef26790cc4942b0fc60957ce3a9d0854c759a20994b106b99defa5385a80dcca?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/ef26790cc4942b0fc60957ce3a9d0854c759a20994b106b99defa5385a80dcca?s=96&d=mm&r=g","caption":"Mohit Sharma"},"description":"I\u2019m Mohit Sharma, a content writer at Bluehost who focuses on WordPress. I enjoy making complex technical topics easy to understand. When I\u2019m not writing, I\u2019m usually gaming. With skills in HTML, CSS, and modern IT tools, I create clear and straightforward content that explains technical ideas.","sameAs":["https:\/\/www.linkedin.com\/in\/mohitsharma066\/"],"honorificPrefix":"Mr","birthDate":"1996-10-06","gender":"male","knowsAbout":["HTML","WordPress","Writing"],"knowsLanguage":["English","Hindi"],"jobTitle":"Web Content Writer","worksFor":"Newfold Digital","url":"https:\/\/www.bluehost.com\/blog\/author\/mohit-sharma\/"}]}},"authors":[{"term_id":842,"user_id":138,"is_guest":0,"slug":"mohit-sharma","display_name":"Mohit Sharma","avatar_url":"https:\/\/secure.gravatar.com\/avatar\/ef26790cc4942b0fc60957ce3a9d0854c759a20994b106b99defa5385a80dcca?s=96&d=mm&r=g","0":null,"1":"","2":"","3":"","4":"","5":"","6":"","7":"","8":"","9":"","10":"","11":"","12":"","13":"","14":"","15":""}],"_links":{"self":[{"href":"https:\/\/www.bluehost.com\/blog\/wp-json\/wp\/v2\/posts\/246438","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.bluehost.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bluehost.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bluehost.com\/blog\/wp-json\/wp\/v2\/users\/138"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bluehost.com\/blog\/wp-json\/wp\/v2\/comments?post=246438"}],"version-history":[{"count":1,"href":"https:\/\/www.bluehost.com\/blog\/wp-json\/wp\/v2\/posts\/246438\/revisions"}],"predecessor-version":[{"id":246478,"href":"https:\/\/www.bluehost.com\/blog\/wp-json\/wp\/v2\/posts\/246438\/revisions\/246478"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.bluehost.com\/blog\/wp-json\/wp\/v2\/media\/240661"}],"wp:attachment":[{"href":"https:\/\/www.bluehost.com\/blog\/wp-json\/wp\/v2\/media?parent=246438"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bluehost.com\/blog\/wp-json\/wp\/v2\/categories?post=246438"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bluehost.com\/blog\/wp-json\/wp\/v2\/tags?post=246438"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.bluehost.com\/blog\/wp-json\/wp\/v2\/ppma_author?post=246438"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}