Code Igniter gives 404 when accessing pages without index.php - php

I'm getting 404 errors when accessing via:
http://www1.example.me/z/account/login
Although these work fine:
http://www1.example.me/z/index.php/account/login
http://www1.example.me/z/
.htaccess - got it from this website:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
### Canonicalize codeigniter URLs
# If your default controller is something other than
# "welcome" you should probably change this
RewriteRule ^(home(/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 www
# If you have subdomains, you can add them to
# the list using the "|" (OR) regex operator
RewriteCond %{HTTP_HOST} !^(www|www1) [NC]
RewriteRule ^(.*)$ http://www1.sherzod.me/z/$1 [L,R=301]
# Enforce NO www
#RewriteCond %{HTTP_HOST} ^www [NC]
#RewriteRule ^(.*)$ http://www1.sherzod.me/z/$1 [L,R=301]
###
# Removes access to the system folder by users.
# Additionally this will allow you to create a System.php controller,
# previously this would not have been possible.
# 'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/$1 [L]
# Checks to see if the user is attempting to access a valid file,
# such as an image or css document, if this isn't true it sends the
# request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
# Without mod_rewrite, route 404's to the front controller
ErrorDocument 404 /index.php
</IfModule>
Configs:
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
$route['default_controller'] = "home";
UPDATE:
Getting this in error_log:
[Wed Dec 28 17:54:30 2011] [notice] cannot use a full URL in a 401 ErrorDocument directive --- ignoring!
Never mind, fixed it.
Should have been:
RewriteRule ^(.*)$ z/index.php/$1 [L]
instead of
RewriteRule ^(.*)$ index.php/$1 [L]
because the code is inside of z folder. Thanks for visiting. :)

Whilst you have 'solved' your problem in your question, your implementation is actually incorrect.
To correctly implement this you should change the RewriteBase directive rather than pointing your rules specifically at a folder.
In your case
RewriteBase /z/
On a side note, rather than amending your question to say you've fixed it, you should post an answer to the same effect. This prevents the question appearing in unanswered feeds etc.

first you go to config file....
then set $config['index_page'] = ' ';
then create one file with .htacess extension and write below code in that and save in root directory
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

Yes, you can easily remove the index.php from url from .htaccess, please check this url for more detail.

Related

laravel API routs return 404 error in 000webhost [duplicate]

I have a problem whereby google has indexed some pages with the wrong url.
The url they are indexing is:
http://www.example.com/index.php/section1/section2
I need it to redirect to:
http://www.example.com/section1/section2
.htaccess isn't my forte, so any help would be much appreciated.
The original answer is actually correct, but lacks explanation. I would like to add some explanations and modifications.
I suggest reading this short introduction https://httpd.apache.org/docs/2.4/rewrite/intro.html (15mins) and reference these 2 pages while reading.
https://httpd.apache.org/docs/2.4/mod/mod_rewrite.html
https://httpd.apache.org/docs/2.4/rewrite/flags.html
This is the basic rule to hide index.php from the URL. Put this in your root .htaccess file.
mod_rewrite must be enabled with PHP and this will work for the PHP version higher than 5.2.6.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) /index.php/$1 [L]
Think %{REQUEST_FILENAME} as the the path after host.
E.g. https://www.example.com/index.html, %{REQUEST_FILENAME} is /index.html
So the last 3 lines means, if it's not a regular file !-f and not a directory !-d, then do the RewriteRule.
As for RewriteRule formats:
So RewriteRule (.*) /index.php/$1 [L] means, if the 2 RewriteCond are satisfied, it (.*) would match everything after the hostname. . matches any single character , .* matches any characters and (.*) makes this a variables can be references with $1, then replace with /index.php/$1. The final effect is to add a preceding index.php to the whole URL path.
E.g. for https://www.example.com/hello, it would produce, https://www.example.com/index.php/hello internally.
Another key problem is that this indeed solve the question. Internally, (I guess) it always need https://www.example.com/index.php/hello, but with rewriting, you could visit the site without index.php, apache adds that for you internally.
Btw, making an extra .htaccess file is not very recommended by the Apache doc.
Rewriting is typically configured in the main server configuration
setting (outside any <Directory> section) or inside <VirtualHost>
containers. This is the easiest way to do rewriting and is recommended
To remove index.php from the URL, and to redirect the visitor to the non-index.php version of the page:
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]
This will cleanly redirect /index.php/myblog to simply /myblog.
Using a 301 redirect will preserve Google search engine rankings.
RewriteEngine On
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(.*)index\.php($|\ |\?)
RewriteRule ^ /%1 [R=301,L]
Assuming the existent url is
http://example.com/index.php/foo/bar
and we want to convert it into
http://example.com/foo/bar
You can use the following rule :
RewriteEngine on
#1) redirect the client from "/index.php/foo/bar" to "/foo/bar"
RewriteCond %{THE_REQUEST} /index\.php/(.+)\sHTTP [NC]
RewriteRule ^ /%1 [NE,L,R]
#2)internally map "/foo/bar" to "/index.php/foo/bar"
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ /index.php/$1 [L]
In the spep #1 we first match against the request string and capture everything after the /index.php/ and the captured value is saved in %1 var. We then send the browser to a new url.
The #2 processes the request internally. When the browser arrives at /foo/bar , #2rule rewrites the new url to the orignal location.
Steps to remove index.php from url for your wordpress website.
Check you should have mod_rewrite enabled at your server.
To check whether it's enabled or not - Create 1 file phpinfo.php at your root folder with below command.
<?php
phpinfo?();
?>
Now run this file - www.yoursite.com/phpinfo.php and it will show mod_rewrite at Load modules section.
If not enabled then perform below commands at your terminal.
sudo a2enmod rewrite
sudo service apache2 restart
Make sure your .htaccess is existing in your WordPress root folder, if not create one .htaccess file
Paste this code at your .htaccess file :-
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Further make permission of .htaccess to 666 so that it become writable and now you can do changes in your wordpress permalinks.
Now go to Settings -> permalinks -> and change to your needed url format.
Remove this code /index.php/%year%/%monthnum%/%day%/%postname%/
and insert this code on Custom Structure: /%postname%/
If still not succeeded then check your hosting, mine was digitalocean server, so I cleared it myself
Edited the file /etc/apache2/sites-enabled/000-default.conf
Added this line after DocumentRoot /var/www/html
<Directory /var/www/html>
AllowOverride All
</Directory>
Restart your apache server
Note: /var/www/html will be your document root
Do the following steps
1. Make sure that the hosting / your pc mod_rewrite module is active. if not active then try to activate in a way, open the httpd.conf file. You can check this in the phpinfo.php to find out.
change this setting :
#LoadModule rewrite_module modules/mod_rewrite.so
to be and restart wamp
LoadModule rewrite_module modules/mod_rewrite.so
2. Then go to .htaccess file, and try to modify to be:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\?*$ index.php/$1 [L,QSA]
if above does not work try with this:
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
3. Move .htaccess file to root directory, where is index.php there.
www OR root folder
- index.php
- .htaccess
Some may get a 403 with the method listed above using mod_rewrite. Another solution to rewite index.php out is as follows:
<IfModule mod_rewrite.c>
RewriteEngine On
# Put your installation directory here:
RewriteBase /
# Do not enable rewriting for files or directories that exist
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>
I have used many codes from the above mentioned sections for removing index.php form the base url. But it was not working from my end. So, you can use this code which I have used and its working properly.
If you really need to remove index.php from the base URL then just put this code in your htaccess.
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]
This will work, use the following code in .htaccess file
RewriteEngine On
# Send would-be 404 requests to Craft
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/(favicon\.ico|apple-touch-icon.*\.png)$ [NC]
RewriteRule (.+) index.php?p=$1 [QSA,L]
I don't have to many bulky code to give out just a little snippet solved the issue for me.
i have https://example.com/entitlements/index.php rather i want anyone that types it to get error on request event if you type https://example.com/entitlements/index
you will still get error since there's this word "index" is contained there will always be an error thrown back though the content of index.php will still be displayed properly
cletus post on "https://stackoverflow.com/a/1055655/12192635" which
solved it
Edit your .htaccess file with the below
to redirect people visiting https://example.com/entitlements/index.php to 404 page
RewriteCond %{THE_REQUEST} \.php[\ /?].*HTTP/
RewriteRule ^.*$ - [R=404,L]
to redirect people visiting https://example.com/entitlements/index to 404 page
RewriteCond %{THE_REQUEST} \index[\ /?].*HTTP/
RewriteRule ^.*$ - [R=404,L]
Not withstanding we have already known that the above code works with already existing codes on stack see where i applied the code above just below the all codes at it end.
# The following will allow you to use URLs such as the following:
#
# example.com/anything
# example.com/anything/
#
# Which will actually serve files such as the following:
#
# example.com/anything.html
# example.com/anything.php
#
# But *only if they exist*, otherwise it will report the usual 404 error.
Options +FollowSymLinks
RewriteEngine On
# Remove trailing slashes.
# e.g. example.com/foo/ will redirect to example.com/foo
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ /$1 [R=permanent,QSA]
# Redirect to HTML if it exists.
# e.g. example.com/foo will display the contents of example.com/foo.html
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.+)$ $1.html [L,QSA]
# Redirect to PHP if it exists.
# e.g. example.com/foo will display the contents of example.com/foo.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+)$ $1.php [L,QSA]
RewriteCond %{THE_REQUEST} \.php[\ /?].*HTTP/
RewriteRule ^.*$ - [R=404,L]
RewriteCond %{THE_REQUEST} \index[\ /?].*HTTP/
RewriteRule ^.*$ - [R=404,L]
try this, it work for me
<IfModule mod_rewrite.c>
# Enable Rewrite Engine
# ------------------------------
RewriteEngine On
RewriteBase /
# Redirect index.php Requests
# ------------------------------
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteCond %{THE_REQUEST} !/system/.*
RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,L]
# Standard ExpressionEngine Rewrite
# ------------------------------
RewriteCond $1 !\.(css|js|gif|jpe?g|png) [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>
For more detail
create .htaccess file on project root directory and put below code for remove index.php
RewriteEngine on
RewriteCond $1 !^(index.php|resources|robots.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

.htaccess returning mod_rewrite redirect to the index page of the www folder of wamp

I am trying to create "pretty urls for dynamically created pages. My desire is to render all pages from the index page.
I am working on my computer using wamp 2.5/apache 2.4.9
The apache httpd.conf is set to:
Listen 0.0.0.0:7080
Listen [::0]:7080
DocumentRoot "c:/wamp/www/"
ServerName localhost:7080
I have tried several different approaches which have resulted in everything from a blank page returning to a 404 error page. With the code below it returns to the index.php in the /www/ folder in wamp.
This is my non-working .htaccess code:
# Turn Rewrite Engine
Options +FollowSymLinks
RewriteEngine on
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-l
# Pages
RewriteRule ^([a-zA-Z0-9]+)$ index.php?topic=$1
# Rewrite to www.
RewriteCond %{HTTP_HOST} ^localhost:7080/demo [nc]
RewriteRule ^(.*)$ http://www.localhost:7080/demo/$1 [r=301,nc]
The clupret line of code is this I believe:
RewriteRule ^([a-zA-Z0-9]+)$ index.php?topic=$1
which I am thinking is some sort of path issue but am not sure... any assistance would be appreciated.
The URL in the address is: http://localhost:7080/demo/test where demo is the site folder in the wamp/www/
http://localhost:7080/demo/test/ (with the forward slash) returns a 404 error.
Your htaccess is lacking a rewrite base.
Just after: RewriteEngine on
Add RewriteBase /demo/
It is strictly not allowing trailing slashes
Replace this line: RewriteRule ^([a-zA-Z0-9]+)$ index.php?topic=$1
withthis code:
RewriteCond %{REQUEST_URI} !-f
RewriteRule ^([a-zA-Z0-9]+)$ index.php?username=$1 [N,L]
This will allow urls ending trailing slashes to force back to your redirect url.
Remove this from the last line:
http://www.localhost:7080.
Leave it as just: /demo/$1 [r=301,nc]
The second to the last line is not doing a lot. You can do and I will advice you do away with it.
Please do remember that when leaving the localhost environment for an online host, replace all incidence of "/demo/" with just "/"
Your final htaccess should be someting like this:
# Turn Rewrite Engine
Options +FollowSymLinks
RewriteEngine on
RewriteBase /demo/
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-l
#RewriteCond %{REQUEST_FILENAME} !-d
# Pages
#RewriteCond %{REQUEST_URI} !-f
RewriteRule ^([a-zA-Z0-9]+)$ index.php?username=$1 [N,L]
# Rewrite to www.
RewriteRule ^(.*)$ /demo/$1 [r=301,nc]
I hope this helps
Try these rules in /demo/.htaccess:
Options +FollowSymLinks
RewriteEngine on
RewriteBase /demo/
# Rewrite to www.
#RewriteCond %{HTTP_HOST} ^localhost$ [NC]
#RewriteRule ^ http://www.%{HTTP_HOST}:7080%{REQUEST_URI} [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([a-zA-Z0-9]+)/?$ index.php?topic=$1 [L,QSA]

mod_rewrite issue in code igniter

Setting
'RewriteBase /'
on production site and
'RewriteBase /mysitefolder'
on development site solved this, hope this helps another guy.
I have a big issue with modRewrite and Codeigniter, and I have these rewrite rules:
### GO TO GODPANEL
RewriteRule ^/godpanel$ /panel/godpanel [L]
I can't make this rule rewrite my page in this way:
myhosting.com/godpanel
to
myhosting.com/panel/godpanel
It keeps saying this pages doesn't exist. I can't make other rules to work properly,
the only rule that works is the original that rewrites the index.php
# If your default controller is something other than
# "welcome" you should probably change this
RewriteRule ^(start(/index)?|index(\.php)?)/?$ / [L,R=301]
RewriteRule ^(.*)/index/?$ $1 [L,R=301]
Hope you can understand me. Thanks!
(EDITED)
Well something changed since yesterday,
when I point to localhost/mysite.com/mycontroller it works,
now when i poin to localhost/mysite.com/godpanel
the url changes to localhost/panel/godpanel
seems that the rules is apllying but in a wrong way
im so noob with regexp in mod rewrite files :(
heres my entire file
#RewriteEngine on
#RewriteCond $1 !^(index\.php|public|robots\.txt)
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule ^(.*)$ index.php/$1 [L,QSA]
<IfModule mod_rewrite.c>
RewriteEngine On
### GO TO GODPANEL
RewriteRule ^godpanel$ /weird/stuff [R=301,L]
### Canonicalize codeigniter URLs
# If your default controller is something other than
# "welcome" you should probably change this
RewriteRule ^(start(/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]
###
# Checks to see if the user is attempting to access a valid file,
# such as an image or css document, if this isn't true it sends the
# request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
# Without mod_rewrite, route 404's to the front controller
ErrorDocument 404 /index.php
</IfModule>
Make sure that the godpanel rule is above all your other rules.
Secondly try removing the forward slash from the start of the ^/godpanel part of your rule:
RewriteRule ^godpanel$ /panel/godpanel [R=301,L]

redirecting to codeigniter controller using htaccess

This is the url
http://rapidsurfing.net/visio/xip8yT
My site is developed in codeigniter. So when link this above url I want to go to one controller function. How can I do this using htaccess.
This is my httaccces code
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^p\/(.*)$ page.php?q=$1 [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?admin/index/url=$1 [QSA,L]
</IfModule>
The url have value xip8yT.The admin is the controller name and index is the function in that controller.
But when I paste the url http://rapidsurfing.net/visio/xip8yT in address bar it load 404 not found error.
What is the problem or mistake in my code?
My default controller is admin.
First make sure you set up your default controller in routes.php file. A complete answer to your question is the way that I worked with CI. CodeIginter itself recommend to use a .htaccess for redirecting all of requests to your index page and your default controller and it's what you did. But I recommend to use this piece of code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /yourbasefoldername
### Canonicalize codeigniter URLs
# If your default controller is something other than
# "welcome" you should probably change this
RewriteRule ^(yourdefaultcontrollername(/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 www
# If you have subdomains, you can add them to
# the list using the "|" (OR) regex operator
# RewriteCond %{HTTP_HOST} !^(www|subdomain) [NC]
# RewriteRule ^(.*)$ http://localhost/dfgamez/$1 [L,R=301]
# Enforce NO www
# RewriteCond %{HTTP_HOST} ^www [NC]
# RewriteRule ^(.*)$ http://localhost/dfgamez/$1 [L,R=301]
###
# Removes access to the system folder by users.
# Additionally this will allow you to create a System.php controller,
# previously this would not have been possible.
# 'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/$1 [L]
# Checks to see if the user is attempting to access a valid file,
# such as an image or css document, if this isn't true it sends the
# request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
# Without mod_rewrite, route 404's to the front controller
ErrorDocument 404 /index.php
</IfModule>
Simply you'll get every slashes after the site address to your index function parameters.
Peace Out!

Symfony 1.3.6 - javascript popup windw - how?

I am using SF 1.3.6. I have some static text files (HTML) that I want to be able to display in a popup window.
I tried this:
foobar<br />
<script type="text/javascript">
function showPopup(url, title) { window.open(url,title,"menubar=no,width=430,height=360,toolbar=no");}
</script>
I get an sf404Exception when I click on the link. How may I fix this?
Note: I dont really want to write a route, and action and a template for these static files - is there another way to achieve popups with SF?
[Edit]
This is my original .htaccess content.
<IfModule mod_rewrite.c>
RewriteEngine On
#force everything to www so URLs look the same
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
# uncomment the following line, if you are having trouble
# getting no_script_name to work
#RewriteBase /
# we skip all files with .something
#RewriteCond %{REQUEST_URI} \..+$
#RewriteCond %{REQUEST_URI} !\.html$
#RewriteRule .* - [L]
#redirect on trailing slash (otherwise, Symfony will 404)
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [R=302,L]
# we check if the .html version is here (caching)
RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
# no, so we redirect to our front web controller
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
I replaced it with Jeremy's script. I then restarted Apache but I am getting the same error
404 | Not Found | sfError404Exception
Empty module and/or action after
parsing the URL "/foobar.html" (/).
The default Symfony .htaccess file should have a line to serve files that already exist in the web directory. Make sure that the path your specifying for the file exists inside of web. Here's the relevant lines from .htaccess:
# we check if the .html version is here (caching)
RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
Here's my full .htaccess with some other improvements:
<IfModule mod_rewrite.c>
RewriteEngine On
#force everything to www so URLs look the same
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
# uncomment the following line, if you are having trouble
# getting no_script_name to work
#RewriteBase /
# we skip all files with .something
#RewriteCond %{REQUEST_URI} \..+$
#RewriteCond %{REQUEST_URI} !\.html$
#RewriteRule .* - [L]
#redirect on trailing slash (otherwise, Symfony will 404)
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [R=302,L]
# we check if the .html version is here (caching)
RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
# no, so we redirect to our front web controller
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
Try adding a leading "/" to foobar.html.
javascript:showPopup('/foobar.html', 'all about foobar')
If you're in a dev environment, then calling foobar.html would actually be calling frontend_dev.php/foobar.html. Adding the leading "/" strips out the frontend_dev.php.
Where do you store your static files? To access them with /foobar.html you need to put 'em in the web/ directory.
Also, remember to make them readable by the web server.

Categories