Note that there are some explanatory texts on larger screens.

plurals
  1. POCan 2 .htaccess files block URL rewriting
    primarykey
    data
    text
    <p>I have a codeigniter project inside the b1 folder in my public_html folder:</p> <pre><code>mydomain.com/b1/controller/function </code></pre> <p>I want to change it to:</p> <pre><code>mydomain.com/controller/function </code></pre> <p>in the browser bar using a 301 redirect.</p> <p>My .htaccess file in my public_html has:</p> <pre><code>RewriteEngine on RewriteRule ^b1/(.*)$ /$1 [R=301,L,NC] RewriteRule ^(.*)$ b1/$1 EXPLANATION: RewriteRule ^b1/(.*)$ /$1 [R=301,L,NC] # THIS IS TO REWRITE ALL REQUESTS FROM THE NAVBAR IN MY PROJECT WHICH HAVE THE FORM mydomain.com/b1/controller/function TO mydomain.com/controller/function. AFTER THIS THE NAVBAR SHOULD SHOW mydomain.com/controller/function ( I ASSUME ) RewriteRule ^(.*)$ b1/$1 # THIS IS TO TAKE ALL INCOMING REQUESTS AND ADD A b1 IN FRONT SO mydomain.com/controller/function IS REDIRECTED TO mydomain.com/b1/controller/function - BUT INTERNALLY, SO THAT THE BROWSERS ADDRESS BAR STILL SHOWS A 'PRETTIER' mydomain.com/controller/function </code></pre> <p>According to <a href="http://htaccess.madewithlove.be/" rel="nofollow">http://htaccess.madewithlove.be/</a>, this should work, but I still see:</p> <pre><code>mydomain.com/b1/controller/function </code></pre> <p>in my address bar.</p> <p>Please note that this is a codeigniter project and CI has the following .htaccess file . ( again the project is in my public_html/b1 directory )</p> <pre><code>RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule .* index.php/$0 [PT,L] </code></pre> <p>As far as I can tell mod_rewrite is working because RewriteRule ^(.*)$ b1/$1 works when a match to the rule above it does not occur.</p> <p>Could some combination of the 2 .htaccess files be causing the lack of visible rerwrite in the address bar? I would like to debug this and figure out how to achieve the URL format discussed above.</p> <p>Thank you,</p> <p>Bill</p> <p>addendum: thanks to everybody for their attempts. what I notice about multiple answers though is that:</p> <pre><code>RewriteRule ^b1/(.*)$ /$1 [R=301,L,NC] RewriteRule ^(.*)$ b1/$1 [L] </code></pre> <p>Their seem to be a lot of L flags . In pseudocode what I want to achieve is:</p> <pre><code>IF REQUEST is mydomain.com or www.mydomain.com ( with nothing after the /) rewrite to mydomain.com . FIRST REWRITE TO REMOVE B1 IF EXISTS ( this is for the navbar requests which have form: mydomain.com/b1/controller/function which should be rewritten to mydomain.com/controller/function ) so that the address bar shows mydomain.com/controller/function </code></pre> <p>if theres an L above , I don't think it will work</p> <pre><code>Then add b1 back in internally so you redirect to b1 folder where project is stored </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload