HtAccess Laravel - laravel

Please find my Laravel website URL below: www.webrox.ae
This website problem is that.. It opens /index.php and for all menu items like portfolio or hire us etc it it opens name/oservices/public/portfolio.. Something like this,....
Below is my htaccess file
Please Guide
#Alternate default index page
DirectoryIndex www.webrox.ae/index.php
# BlueHost.com
# .htaccess main domain to subdirectory redirect
# Do not change this line.
RewriteEngine on
# Change example.com to be your main domain.
# Change 'subdirectory' to be the directory you will use for your main domain.
# Don't change the following two lines.
# Change 'subdirectory' to be the directory you will use for your main domain.
RewriteCond %{HTTP_HOST} ^(www.)?webrox.ae$
RewriteCond %{REQUEST_URI} !^/oservice/public/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /oservice/public/$1
# Change example.com to be your main domain again.
# Change 'subdirectory' to be the directory you will use for your main domain
# followed by / then the main file for your site, index.php, index.html, etc.
RewriteCond %{HTTP_HOST} ^(www.)?webrox.ae$
RewriteRule ^(/)?$ webrox.ae/index.php [L]
RewriteCond %{HTTP_HOST} ^www\.webrox\.ae$
RewriteRule ^/?$ "http\:\/\/webrox\.ae\/" [R=301,L]
Thanks

Change the line from
RewriteCond %{REQUEST_URI} !^/oservice/public/
RewriteRule ^(/)?$ webrox.ae/index.php [L]
to
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^(/)?$ webrox.ae [L]
And add the line
RewriteRule ^ index.php [L]

Related

change document root with .htaccess internal redirect not working properly

Hello my fellow developers,
i need to change my document root some specific folder which holds the source code of my laravel project on a shared hosting, since my hosting plan dont let me change default document root so i cannot change my default index so i want to have to redirect it using .htaccess
for far i have been able to internally redirect with the following code
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com$
RewriteRule ^(.*)$ master/project/public/index.php
doing this i am able to redirect to desired folder, but for some reason it is not working for assets, i keep getting 404 on all the assets
master/project/public/css/[all styles]
master/project/public/js/[all scritps]
master/project/public/images/[all pictures]
master/project/public/fonts/[all fonts]
how can i achieve this without having to change urls,
internal redirect is working but i cannot figure out why all of my assets are returning 404
Try this
i m using shared hosting and this i m using for redirect asset to public dir
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
#all request to public dir
RewriteEngine on
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ public/$1 [L]
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
To redirect all request to public
#all request to public dir
RewriteEngine on
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ public/$1 [L]
so i found solution to my problem,
this solution is what i ended up with.
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www.example.com$
RewriteCond %{REQUEST_URI} !master/project/public/
RewriteRule (.*) /master/project/public/$1 [L]
this way you can change the default root of the your hosting using .htaccess file. hopefully it is helpful for everybody new to .htaccess

.htaccess rewriting folder url

I have a Laravel app that resides in a folder in a Wordpress based website. Name of folder is "artists". It is a database app to list local artists.
I need help rewriting url using .htaccess
Current URL
https://example.ca/artists/artists/name-of-artist
Desired URL
https://example.ca/artists/name-of-artist
Any help would be greatly appreciated. Thanks !
Here is the current .htaccess in the root folder of the Laravel app (artists)
#<IfModule mod_rewrite.c>
#RewriteEngine On
#RewriteRule ^(.*)$ public/$1 [L]
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ ^$1 [N]
RewriteCond %{REQUEST_URI} (\.\w+$) [NC]
RewriteRule ^(.*)$ public/$1
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ server.php
The correct command you are advised to use is "RedirectMatch 301". Add the following line into ".htaccess" inside public folder of Laravel:
RewriteEngine On
# Custom Rule START #
RedirectMatch 301 ^/artists/artists/(.*)$ /artists/$1
# Custom Rule END #

Redirect user using htaccess in my Laravel application

I am having trouble with my configuration of htaccess in my laravel application.
I am using the following codes to redirect user to the right path. I tried to add host_name to my htaccess but it breaks the inner pages of the application.
IP address redirection is working fine now.
File : laravel_app/public/.htaccess
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
RewriteCond %{HTTP_HOST} ^10\.10\.10\.201$
# RewriteCond %{HTTP_HOST} ^host_name$ -- It breaks the other page.
RewriteRule (.*) http://host_name.maindomain.com/$1 [R=301,L]
</IfModule>
User can manually navigate to the ff:
http://host_name/login
http://10.10.13.201/login
But i want them to use the rigth path below :
http://host_name.maindomain.com/login
Is this achievable using htaccess?
Edit :
http://host_name.maindomain.com is pointed to laravel_app/public.
You can not chain the RewriteCond, so your .htaccess has an invalid configuration since it will only try to bind the last condition and the first one has no corresponding rule:
Try something like this:
RewriteCond %{HTTP_HOST} ^10\.10\.13\.201$
RewriteRule (.*) http://host_name.maindomain.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^host_name$
RewriteRule (.*) http://host_name.maindomain.com/$1 [R=301,L]
See the demo

.htaccess file for magento in subdirectory

We are finding it difficult to remove the redirection of my /admin to /index.php/admin, which is not allowing us to access the admin panel, at every url that should start with /admin/ gets redirected to /index.php/admin/ and it displays No input file specified. and when i remove index.php from the url it works fine.
My .htaccess file looks like this
DirectoryIndex /new/magento-k/index.php
RewriteEngine on
RewriteBase /mysubdirectory/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|robots\.txt)
RewriteCond %{REQUEST_URI} !^/admin.*
RewriteCond %{REQUEST_URI} ^/index.php/admin.*$
RewriteRule ^/index.php/admin(.*) /admin$1 [R]
RewriteRule ^(.*)$ index.php?/$1 [L]
RewriteRule ^/index.php/(admin|user)($|/) - [L]
Options -MultiViews
Try putting this into your .htaccess file
RewriteRule .* /index.php [L]
and remove the other index.php rule:
RewriteRule ^/index.php/(admin|user)($|/) - [L]
Also make sure to clear cache of Magento and your browser.

htaccess file for codeigniter on subdomain virtualhost

i have problem about .htaccess file for my codeigniter installation.
On localhost this work fine, when i upload online its rewrite URL but the website not work.
this is my htaccess on localhost:
RewriteEngine On
RewriteBase /jCore_01/
#RewriteBase /
### Canonicalize codeigniter URLs
# If your default controller is something other than
# "welcome" you should probably change this
RewriteRule ^(welcome(/index)?|index(\.php)?)/?$ / [L,R=301]
RewriteRule ^(.*)/index/?$ $1 [L,R=301]
# Removes trailing slashes (prevents SEO duplicate content issues)
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ $1 [L,R=301]
# Enforce NO www
#RewriteCond %{HTTP_HOST} ^www [NC]
#RewriteRule ^(.*)$ http://domain.tld/$1 [L,R=301]
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
online i have a problem:
i put this file on subdomain jcore.miodomio.com and it rewrite URL but not work
example:
without htaccess it's work:
jcore.miodominio.com/index.php/en/home
with htaccess
jcore.miodominio.com/en/home
Not Found
The requested URL /en/home was not found on this server.
can anyone help me? suggestion?
regards
Denny
Try change your htaccess to:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]
Somethings to consider.
Did you enable Apache rewrite module?
If enabled check whether your virtual host file is configured properly So to make sure its hitting .htaccess or try putting some dump on .htacess , So if its hitting .htaccess than you should get an 500 server error.
If you are not getting error than its mostly the problem in your host settings.

Resources