John Davidson

php - htaccess redirect not working on src folder

0 comments
Message:


UPDATE: This is working very well. I just needed to put my SRC folder inside the public folder.


I've asked a Q about this before but it's not working well.


I have a folder called "listing"


Inside the folder, I have two other main folders called "public" and "src".


Like this...


<pre>
public -> some index.php + other pages and files here.
</pre>
<pre>
src -> some backend files and logic here.
</pre>


I want to redirect both the public and the src folder to the root directory


So when a user visits the website, instead of localhost/public/index.php, they'll see index.php


I have created the .htacess file and added the following codes to it


RewriteBase /listing/

RewriteCond %{THE_REQUEST} /public/([^\s?]*) [NC]
RewriteRule ^ %1 [L,NE,R=302]

RewriteRule ^((?!public/).*)$ public/$1 [L,NC]

But as you can see, the redirect is only pointing to the public folder. Any way to add the src folder, please? I'm tired of searching lol.



My Answer:
src in my project directory, and I want to redirect all requests to this folder to a different location using an htaccess file. Here's what I have in my htaccess file:


RewriteEngine On
RewriteRule ^src/(.*)$ /new_location/$1 [L,R=301]


However, when I try to access a file in the src folder, the redirect doesn't seem to be working. I've tried different variations of the RewriteRule but none of them seem to work.

Is there something I'm missing or doing wrong in my htaccess file? Any help would be appreciated.

Rate this post

4 of 5 based on 7065 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us