I need to run a zend1 app on my local system which is working on a production server successfully.
The problem I'm facing currently is that when I run it through localhost/example it shows me nothing, just a blank page and when I try to call a controller directly like localhost/example/controller1 it moves to 404.
I've searched the issue on Google and tried to implement all the possible solutions, but no luck.
Here is the .htaccess of the app
RewriteEngine on
RewriteCond %{HTTP_REFERER} semalt\.com [NC]
RewriteRule .* - [F]
RewriteBase /
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^media\/\.cache\/(.*)$ image.php?file=$1 [L]
RewriteRule ^([a-zA-Z0-9\_\/\\\-]+)?$ index.php [L]
You don't need to write to much things in .htaccess.
you can use this few line code for .htaccess file.
and you need to put this .htaccess file and index.php file on root folder.
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
Options -Indexes
Related
I know that this question has been asked a lot, but nothing I've seen so far worked.
I have a wp in root, running from subdirectory (I like things clean). I also a few subdomains running from subdirectories in root (eg. public_html/sample.com). I get the error only on subdomains that are pure HTML and CSS. They don't use any platform.
Here's my .htaccess from root
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Things I've tried:
1) Comment out all RewriteRule - solves the problem, but then my wp doesn't work. It gives 404 error when I go to any posts or pages.
2) Changed the .htaccess to the following (courtesy of Scott Yang):
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ /index.php/$1 [L,QSA]
</IfModule>
but that didn't change anything.
3) I also tried commenting out and pasting new code from other questions, quite on random, but it's the same story.
Any ideas?
Cheers
I've found a solution.
In the root directory for the subdomain, in the .htaccess add the following:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
Rewrite Rule ^([^.]+)$ $1.php [NC,L]
This is how you can get rid of .php from the end of URL.
Replace .php with .html and it also gets rid of .html
For some reason, this fixes the problem.
Cheers
EDIT:
This solved the problem, but it didn't remove the .html from the URL. Below worked perfectly
#example.com/page will display the contents of example.com/page.html
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.+)$ $1.html [L,QSA]
#301 from example.com/page.html to example.com/page
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*\.html\ HTTP/
RewriteRule ^(.*)\.html$ /$1 [R=301,L]
Cheers
I have installed my wordpress installation on my server root e.g mydomain.com & codeigniter installed in subdirectory named ci e.g mydomain.com/ci. When I try to access my wordpress site it works fine, but when I try to access any of my ci controllers e.g mydomain.com/ci/signup it throw 404 Page Not Found CI error. but it worked fine for my default home controller. I have searched for solution & tried many of them but any one of them is not worked in my case.
here is the rewrite rules in .htaccess for my both installtion.
mydomain.com/.htaccess
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
mydomain.com/ci/.htaccess
RewriteEngine on
RewriteBase /ci
RewriteCond $1 !^(index\.php|user_guide|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
I think the problem is with wordpress .htaccess file. We should have to route the request that is for ci to ci folder.
This code might help, add this to wordpress .htaccess file
RewriteRule ^$ ci/$1 [L]
RewriteRule ^(.*) ci/$1 [L]
I am trying to deploy an Fat Free Framework app on a subdomain. It worked fine on my local server but I get a blank page on deploying it on a sub-domain on a live site. I believe I somehow got my configurations (.htaccess, config/routes) wrong but I've tried several but can't get it to work. My configs are:
.routes file
[routes]
GET /games/#gameid/#move = WebPage->getgames
.config file
[globals]
AUTOLOAD = app/;third_party/;third_party/phpQuery/
DEBUG = 0
UI = views/
ENCODING = utf-8
LOGS= tmp/cache/
.htaccess file
#mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L,QSA]
#Hotlinking Protection
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?subdomain.domain.com/.*$ [NC]
RewriteRule \.(js|css|jpg|gif|png|bmp|mp4|3gp|m4a|m4r|aac|mp3|ogg|wave)$ - [F]
#PHP code in HTML file
AddType fcgid-script .php .htm .html .phtml
I'm on PHP Version 5.3.28 Apache 2.3.7
Folder Structure
subdomain.domain.com (subdomain folder)
.htaccess file
index.php file
app folder
db folder
views folder
third_party folder
tmp folder
On my local server I have .htaccess file like this
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
Allow from ::1
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule .* index.php [L,QSA]
This seems incorrect:
RewriteBase /subdomain.domain.com
I would change it to simply be this:
RewriteBase /
The reason being is RewriteBase only refers to the URL base of the server itself and not anything further “to the left” of that. Meaning if this is your main site URL:
http://subdomain.domain.com
Setting a RewriteBase /subdomain.domain.com would mean that the rules would only act on the URL of :
http://subdomain.domain.com/subdomain.domain.com
And to make it a bit clearer, one would only adjust RewriteBase / (an then the corresponding RewriteRule) if the code is running on a path “to the right” of the base URL. So let’s say you installed it in the directory mycoolapp/ and you wanted that to be accessible like this:
RewriteBase /mycoolapp/
And then you would have to adjust the RewriteRule for the index.php like this:
RewriteRule . /mycoolapp/index.php [L,QSA]
EDIT: Based on you providing the .htaccess for your local setup, you have this for your mod_rewrite:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule .* index.php [L,QSA]
But on your subdomain setup you have this:
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L,QSA]
Why the radical difference? Just use the mod_rewrite stuff that works from your local setup. Specifically get rid of this line on your subdomain setup:
RewriteBase /
And change this line:
RewriteRule . /index.php [L,QSA]
To be this:
RewriteRule .* index.php [L,QSA]
So the final subdomain .htaccess should have this:
#mod_rewrite on
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule .* index.php [L,QSA]
#Hotlinking Protection
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?subdomain.domain.com/.*$ [NC]
RewriteRule \.(js|css|jpg|gif|png|bmp|mp4|3gp|m4a|m4r|aac|mp3|ogg|wave)$ - [F]
#PHP code in HTML file
AddType fcgid-script .php .htm .html .phtml
Apparently it was caused by a php error and because I had show errors turned off, I couldn't see it. It was caught by the support staff of my web host after I uploaded a fresh install of the app and got
Internal Server Error
Fatal error: syntax error, unexpected '['
Specifically my web hosting support staff said it had to do with PHP array dereferencing. I quote partly below
..it looks like a part of your scripts are using array dereferencing
which works on PHP 5.4+, and..
So we switched to PHP 5.4+ and bam everything went into place.
BTW I used the following .htaccess
#mod_rewrite on
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php [L,QSA]
No stress, no fuss.
I'm trying to route all requests to /web/index.php (front controller) while serving static files directly if they exist.
The following .htaccess file was taken from a Symfony 2 application, and seems to work fine as it is. Requests are sent to ./index.php and I can access to static files like ./web/css/style.css. I'm working on a shared hosting (not a good one) and this .htaccess seems the only one working (this will cause a 500 error).
How can I have route all requests to /web folder? It seems that I need to change something in E=BASE variable, I've tried [E=BASE:%1/web] but it doesn't work.
I have a little understanding of rewrite rules, can you point me to the right direction?
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^index\.php(/(.*)|$) %{ENV:BASE}/$2 [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule .? - [L]
# Rewrite all other queries to the front controller.
RewriteRule .? %{ENV:BASE}/index.php [L]
</IfModule>
I may be way off here... but isn't it just: change the last line to:
RewriteRule .? %{ENV:BASE}/web/index.php [L]
For the static files it needs to be looking in your /web folder to check if the file exists. Currently the RewriteCond %{REQUEST_FILENAME} -f just checks if the filepath requested exists.
Try throwing a RewriteBase command in before the RewriteCond %{REQUEST_FILENAME} -f:
RewriteBase /web/
RewriteCond %{REQUEST_FILENAME} -f
You can replace your .htaccess with this code:
RewriteEngine On
RewriteCond %{THE_REQUEST} /index\.php [NC]
RewriteRule ^(.*?)index\.php$ /$1 [L,R=302,NC,NE]
RewriteCond %{REQUEST_FILENAME} -f
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^((?!web/).*)$ web/$1 [L,NC]
Let's assume that your domain is gremo_silex.com, and your hosting has directory for it like
~/domains/gremo_silex.com/public_html
(all hosting services I used last few years had directory structure similar to this).
Then you can place your Silex project one directory up (in ~/domains/gremo_silex.com) and rename your web directory to public_html, this way there's no web in your url's.
I encountered the same issue today. Normally the web host would allow you to change Apache's document root (my preferred method) but in this case it wasn't possible. So with some hackery I compiled this:
<IfModule mod_rewrite.c>
RewriteEngine on
# Serve all public files from /web/
RewriteCond %{REQUEST_URI} !web/
RewriteRule (.*) /web/$1 [L]
# If file doesn't exist send to front controller
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php [QSA,L]
</IfModule>
The REQUEST_URI header comes in to PHP without the /web prefix too, so routing should work out of the box.
I've gone through stackoverflow.com quiet a bit but I believe I didn't find what I was looking for. So, Here it goes. I have a .htaccess file which redirects properly but I have a remote test server, which it seems doesn't redirect as my developer machine does, could that might be the server's apache2 handler isn't configured properly?
Okay, the code is as below.
RewriteRule ^welcome?(.*) public/index.php [L]
RewriteRule ^profile?(.*) public/index.php [L]
RewriteRule ^password?(.*) public/index.php [L]
RewriteRule ^verify(.*) public/index.php [L]
RewriteRule ^(.*)$ main.php?%{QUERY_STRING} [L]
Now, the main.php file handles all the request that comes in, even welcome,profile,password,verify. but Now, I want to redirect specific files only to the public/index.php file, which it does in my developer machine but remote server ?
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteRule ^(welcome|profile|password|verify) public/index.php [NC,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^/(welcome|profile|password|verify) [NC]
RewriteRule ^(.*)$ main.php [QSA,L]
Give this a try.