htaccess file to redirect my pages like
site/pageTitle to index.php?id=pt
and to show article from category
site/article/pageTitle
now .htaccess file considering my image folder as catgory directory and images as pageTitle and does not display images
even when I direct url to image it shows article page
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#show urls like site/author/pageno
RewriteRule ^author/(.*)/(.*)$ index.php?author=$1&page=$2 [NC]
RewriteRule ^author/(.*)?$ index.php?author=$1&page=$2 [NC]
#show articles like site/article/articleTagName
RewriteRule ^article/(.*)/(.*)?$ index.php?article=$1 [NC]
RewriteRule ^article/(.*)?$ index.php?article=$1 [NC]
#direst article site/articleTagName
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?article=$1 [L,QSA]
#set image folder and user folder to real from virtual
RewriteRule ^(.*)/images/$ /images/
Please replace your last line with
RewriteRule ^(.*)/images/(.*)$ images/$2
I was facing the same problem but I got a hint from your coding and changed the code a little bit; now it's working fine.
Related
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]
I have developed a web application on code igniter. This is the first time i am working on code-igniter After developing a web application on my localhost its working fine. But when I hosted the site in server the main index page was opening but the sub pages showing "404 page not found error". Can you please guide me.Here is my htacess file
RewriteBase /
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/system.*
RewriteRule ^(.*) index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+) index.php?/$1 [L]`
and in my routes.php I have added following line
$route['about'] = 'mycontroller/about';
Did you try setting the config ?
$config['base_url'] = "https://www.yoursite.com/";
There is a good tutorial on that at sajjad's blog
Copy the below code in your .htaccess file :
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
my code had all class names starting with uppercase letter, however few posts mentioned changing the file name to match the class name. However, that didn't help. Finally the following helped:
create a file .htaccess and add the following lines of code in it:
RewriteEngine on
RewriteCond $1 !^(index\.php|public|\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1
it should work
I have worked on a website which was has two domain names.It got linked to one of them on one server.On trying the same on another server for a different domain the website gets linked and opens but it is just able to access the default controller.Anything I try other then the default controller it shows page not found.
there is issue with your .htacces file
just try
your.domain.com/index.php/contorller_name/function
if it works then replace your .htaccc file at main folder with this.
RewriteEngine On
RewriteBase /your_project_path
RewriteCond %{REQUEST_URI} ^system.*
RewriteCond $1 !^(index\.php|images|js|uploads|css|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
How to redirect all pages (pages only) to index.html using htaccess file and not redirect the image files. For some reason I am using this code and an image file on the index.html page isn't showing up.
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/index.html$
RewriteRule .* /index.html [L,R=302]
Try this code :
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/index.html$
RewriteCond %{REQUEST_URI} !\.(gif|jpe?g|png|css|js)$
RewriteRule .* /index.html [L,R=302]
Keep your rules simple. Instead of filtering what shouldn't match, just match on the files.
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/index.html$
RewriteRule .*\.(php|html)$ /index.html [L,R=302]
A nicer way might be just to ignore existing files. For example:
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/$
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* / [L,R=302]
The !-d says to ignore the rewrite if there is an existing directory that meets the match.
The !-f says to ignore the rewrite if there is an existing file that meets the match.
Everything else will get rewritten.
You need to add a .htaccess file inside the public directory, so whenever you build your app, it automatically gets copied to the new dist directory. The content of.htaccess should be like:
RewriteEngine On
RewriteBase /
RewriteRule ^index.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
Add the following before the last line
RewriteCond %{REQUEST_URI} !(\.png|\.jpg|\.gif|\.jpeg|\.bmp)$
I have my .htaccess file localhost/site/ folder and a default image defaultcarimage-thumb.jpg in localhost/site/images/car_model/ folder.I want to show this default image instead of main image when original image will not be found. For that I search on google and found this link
And I edit my .htaccess as follows :
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} \.(gif|jpg|jpeg|png)$
RewriteRule .*/images/car_model/defaultcarimage-thumb.jpg [L]
But nothing change. What's wrong with this code? Or Is there any other way to do this?
RewriteRule syntax is RewriteRule _url-send-by-user_ _rewrite-to_
So change your RewriteRule to something like this:
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} \.(gif|jpg|jpeg|png)$
RewriteRule (.*) /images/car_model/defaultcarimage-thumb.jpg [L]
And check the Pathes, both the RewriteBase and RewriteRule-to argument path.