I have got this url:
http://localhost:85/WebCamClone/Home
But it will only load like this:
http://localhost:85/WebCamClone/index.php/Home
I tried to put htaccess rule like this one:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
But it didnt work. What else should I try?
This is what is inside my apache config file:
<Directory />
Options FollowSymLinks
AllowOverride all
Order deny,allow
Deny from all
</Directory>
In application/config/config.php have you removed index.php from $config['index_page'] so that it looks like:
$config['index_page'] = '';
Try with this code once in your .htaccess file
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
The problem was in apaches config file.. I had to go to its file and replace allowoveride none to allow override all
Related
Tried all the possible solutions listed on Stackoverflow - but didn't work. Would love some help here.
Have an application that runs as follows:
localhost/bdl
Have Made the Default controller as 'Measurements'
Now I am making a call to a method within the Measurements controller called measurement_add and I get a 404 .
If I call it using localhost/bdl/index.php/measurements/measurement_add - it works - but not otherwise.
My .htaccess file is as follows:
RewriteEngine on
RewriteRule ^([a-z0-9_-]+)\.html$ /bdl/index.php/page/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|asset|robots\.txt)
RewriteRule ^(.*)$ /bdl/index.php/$1 [L]
My httpd.conf file is :
AllowOverride All
and uncommented the:
LoadModule rewrite_module modules/mod_rewrite.so
Can't figure it out. Any help would be appreciated.
Thanks
please use this below code in your .htaccess
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/system.*
RewriteRule ^(.*)$ index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?/$1 [L]
ErrorDocument 404 index.php
and use below code in your config file
$config['index_page'] =''
first check mod_rewrite is enabled in your apache using phpinfo() function.
Inside your httpd.conf do below change
Options FollowSymLinks
AllowOverride All
Allow from all
In your config.php file set
$config['index_page'] =''
add below code in .htaccess at the root of your application.
RewriteEngine on
AddType application/x-shockwave-flash .swf
#RewriteBase /
RewriteCond $1 !^(index\.php|resources|MobileSiteImage|robots\.txt|flash)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
I'm trying to implement some htaccess rewrite rules. However in not a pro in htaccess.
I have a subdomain gateway in (as described in: .htaccess and rewrite sub domains)
Now i would like to use SEO friendly URL's. The gateway has some subfolders i.e. email in this case.
http://gateway.example.com/email/Param1/Param2/
This url should be rewritten to http://gateway.example.com/email/index.php?hash=Param1&hash2=Param2.
In the email folder I have created a .htaccess file with the following contents:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.* - [L]
RewriteRule ^/(.*)/(.*)/ index.php?hash=$1&hash2=$2
When requesting the http://gateway.example.com/email/Param1/Param2/ i'm now getting a 404. What is wrong with the rule?
You should do it this way
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^/?([^/]*)/([^/]*)/ /email/index.php?hash=$1&hash2=$2 [L]
you can try this.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^/([^/]*)/([^/]*)/ index.php?hash=$1&hash2=$2
*you need to configure apache(httpd) to accept UrlRewrite by changing AllowOverride from non to all like this :
<Directory "/var/www/html">
Options Indexes FollowSymLinks
AllowOverride all
Order allow,deny
Allow from all
</Directory>
I have mod_rewrite enabled on Apache2 and AllowOverride All in the default file. However Apache (After restarting) still can't seem to redirect when given a pretty url from Laravel.
WORKS (Returns: Users!): localhost/laratest/public/index.php/users
DOESN'T WORK (404): localhost/laratest/public/users
My .htaccess: (I've also tried the one suggested in the Documentation to no avail)
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
Laravel routes.php:
Route::get('/', function()
{
return View::make('hello');
});
Route::get('users', function()
{
return 'Users!';
});
I am using the default LAMP stack and configuration in Ubuntu. Any ideas why this isn't working?
Have you set your RewriteBase to /laratest/public?
Options +FollowSymLinks -Indexes
RewriteEngine On
RewriteBase /laratest/public
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
As suggested on the laravel website (http://laravel.com/docs/installation#pretty-urls) try this other one:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
As an experienced web developer, I feel like an idiot posting this. Somehow I tend to have issues with .htaccess. I'm trying to route all requests within /wiki to my index.php with the following...
RewriteEngine On
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ./ /index.php [L]
Virutal host:
<VirtualHost *:80>
ServerName mysite.local
DocumentRoot "/var/www/mysite/public_html"
<Directory "/var/www/mysite/public_html">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
I'm trying to access http://mysite.local/wiki/asdf and getting a 404 error.
Apache's error log shows nothing
If /wiki is an existing folder in your public_html root folder, and your index.php file is in the wiki folder, then you can give the following a try:
RewriteEngine On
RewriteBase /wiki
RewriteRule index\.php - [F,L]
RewriteCond %{REQUEST_URI} !-f
RewriteCond %{REQUEST_URI} !-d
RewriteRule .* index.php [L]
If the wiki folder does not exist, and you're doing all the work at the root:
RewriteEngine On
RewriteBase /
RewriteRule index\.php - [F,L]
RewriteCond %{REQUEST_URI} !-f
RewriteCond %{REQUEST_URI} !-d
RewriteRule wiki/(.*) index.php/$1 [L]
Now give this a try! To rewrite non-existence /wiki and /wiki/ and /wiki/$var into /index.php:
RewriteCond %{REQUEST_URI} ^/wiki/?
RewriteCond %{REQUEST_FILENAME} !-f [OR]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) /index.php
I ended up needing what the Yii Framework uses...
RewriteEngine On
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward it to index.php
RewriteRule . index.php
I am trying to remove php extension from url, But its not working for me. I am using Windows 7, with apache2.2.17 and php5.3. Now I have configured it as
in .htaccess file
OPTIONS -Indexes
IndexIgnore *
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteCond %{REQUEST_URI} !/$
RewriteRule (.*) $1\.php [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ /$1 [R=301,L]
in httpd.conf enabled mod_rewrite as
LoadModule rewrite_module modules/mod_rewrite.so
and
<Directory "D:/Apache/htdocs">
Options Indexes FollowSymLinks ExecCGI MultiViews
AllowOverride all
Order allow,deny
Allow from all
</Directory>
in php.ini
expose_php = On
After making these configuration still i am not able to remove php extension from url in my windows machine but same thing is working in ubuntu server.
Is there anything I am missing here?
This might answer your question:
RewriteRule ^/([^-]*)$ /$1.php
It works for root catalog.
RewriteRule ^catalog/([^-]*)$ catalog/$1.php
Or you can write automatic script:
RewriteRule ^/([^-])/([^-])$ /$1/$2.php
But this is for "httpd.conf" file.
Where: ([^-]*) means variable; $1, $2 means converted to variable i.e.
www.verity.com/foo/bar => verity.com/foo/bar.php
Use this instead:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(([A-Za-z0-9\-]+/)*[A-Za-z0-9\-]+)?$ $1.php
By doing this, you will be able to call example.com/abc.php as example.com/abc