ISAPI ZEND url rewrite adding extra "/index.php/" into url - zend-framework

We recently reinstalled our web site on our server, the sys admin says it is an exact rebuild, and it indeed looks to me that it is, but there is something different going on. I did not originally develop the site, and those who did are no longer available.
urls for the admin site are now
//admin.site.com/index.php/schedules
and used to be, and should be
//admin.site.com/schedules
The extra index.php is getting inserted in the url. But all links within the admin site do not include the index.php so they do not work. If you insert the index.php into any url, it works. Where did this index.php come from and how do I eliminate it from the rewrite rules so the links will work.
This is what my httpd.conf file reads:
# Helicon ISAPI_Rewrite configuration file
# Version 3.1.0.56
# turn on rewriting RewriteEngine On RewriteBase /
# for all files not found in the file system,
# reroute to "index.php" bootstrap script,
# keeping the query string intact.
RewriteCond %{HTTP_HOST} ^admin.site.com$
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteCond %{HTTP_HOST} ^admin.site.com$
RewriteRule ^.*$ index.php [NC,L]
Thank you! Any help would be greatly appreciated.

You need to implement and enable ApacheModrewrite. And then put a .htaccess file in your admin.site.com folder
Its content will be :
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]

Related

.htaccess - rewrite user login in url

I need to rewrite URL with user login and i use Zend Framework.
.htaccess of ZF project are follow:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
How to add rule, with rewrite
http://yourdomain.com/user/TOMMY
to
http://yourdomain.com/user/?login=TOMMY
? Where "TOMMY" is user login.
Important: after rewriting, URL in browser leaves without changes.
I can add next rule:
RewriteRule ^user/([a-zA-Z0-9]+)$ /user/?login=$1 [L,R]
But its not correctly, because server redirect browser to other page.
Tnx.
You need to change the other rule so that it doesn't rewrite URI's that start with "/user/"
RewriteCond %{REQUEST_URI} !^/user/
RewriteRule ^.*$ index.php [NC,L]
Now you can rewrite the /user requests using your rule:
RewriteRule ^user/([a-zA-Z0-9]+)$ /user/?login=$1 [L]
Except you don't want that R in the brackets, because it will redirect the browser and change what's in the address bar.

htaccess issue after connecting domain to subfolder

I have a problem with .htaccess. I have a website in the main server folder and a domain that leads to it (adriatic.pl). No i have made a new version of the website and put it in "adriatic_new" folder. When i run adriatic.pl/adriatic_new/public everythig works fine, but when i connect the domain (adriatic.pl) directly to the "adriatic_new" folder I get "500 Internal Server Error".
I found that it may be .htaccess problem bo how to edit it to make it work?
It looks like this:
SetEnv APPLICATION_ENV development
Allow from all
DirectoryIndex main.php
RewriteEngine On
RewriteCond %{DOCUMENT_ROOT}/static/index.html -f
RewriteRule ^/*$ static/index.html [L]
RewriteCond %{DOCUMENT_ROOT}/static/%{REQUEST_URI}.html -f
RewriteRule .* static/%{REQUEST_URI}.html [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^(.*)/+$
RewriteRule ^.*$ %1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ main.php [NC,L]
php_flag magic_quotes_qpc off
php_flag register_globals off
Ok guys (and ladies?) - problem is solved.
All I had to do was to add "RewriteBase /" in my .htaccess. So simple yet so confusing and annoying. Thanks.

Zend Framework htaccess Backend / Frontend

In my current ZF project, I've two public access points (files) ready to handle & process coming requests, that's: index.php & admin.php
I need all URLs containing '/admin' to be routed to admin.php while any other URLs doesn't contain '/admin' to be routed to index.php
Knowing that default ZF htaccess contains the following rules:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
How this can be implemented?
I want to start by saying that I full heartedly agree with AurelioDeRosa. I do believe that routes will be a better choice. However that is your choice not mine and this .htaccess code should do the trick you want.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*(admin).*$ admin.php [NC,L]
RewriteRule ^.*$ index.php [NC,L]
Note however that this script will catch anything that contains admin so it might break your frontend. for example, if you want to list all your users with administrative rights the url yoursite.com/users/listby/admin/ will redirect the request to admin.php, and so will urls like /administrator/ or /adminininini

How do I get my contact form to work after mod_rewrite?

I've built a site using CMS Made Simple. I have to point the host URL for everything EXCEPT the admin page and the contact forms. I was able to successfully do this with mod_rewrite to the config.php and changing up the .htaccess, but now my contact forms are no longer working (one in the footer and one on the contact page). Here is what my .htaccess file looks like:
Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^energyfa.ipower.com$ [NC]
RewriteCond %{REQUEST_URI} !^/ai/admin/
RewriteRule ^(.*)$ http://accimpress.com/$1 [R=301,L]
# 301 Redirect all requests that don't contain a dot or trailing slash to
# include a trailing slash
# except for form POSTS
RewriteCond %{REQUEST_URI} !/$
RewriteCond %{REQUEST_URI} !\.
RewriteCond %{REQUEST_METHOD} !^POST$
RewriteRule ^(.*) %{REQUEST_URI}/ [R=301,L]
# Rewrites urls in the form of /parent/child/
# but only rewrites if the requested URL is not a file or directory
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?page=$1 [QSA]
Is there a reason my POST exception might not be working? Any suggestions will be much obliged. The website is: http://energyfa.ipower.com/ai/
Thanks,
Cory
try changing your .htaccess from
# .htaccess for CMS made simple
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !/$
RewriteCond %{REQUEST_URI} !\.
RewriteCond %{REQUEST_METHOD} !POST$
RewriteRule ^(.*) %{REQUEST_URI}/ [NE,R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f [NC]
RewriteCond %{REQUEST_FILENAME} !-d [NC]
RewriteRule ^(.+)$ index.php?page=$1 [QSA]
# EOF
to
# .htaccess for CMS made simple
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !$ <--- to put the "/" ---->
RewriteCond %{REQUEST_URI} !\.
RewriteCond %{REQUEST_METHOD} !POST$
RewriteRule ^(.*) %{REQUEST_URI} [NE,R=301,L] <--- to put the "/" after } ---->
RewriteCond %{REQUEST_FILENAME} !-f [NC]
RewriteCond %{REQUEST_FILENAME} !-d [NC]
RewriteRule ^(.+)$ index.php?page=$1 [QSA]
# EOF
it work for us
I see that the action on your form is set to http://energyfa.ipower.com/ai/contact-us/. What I believe will happen is that the POST will go to that URL. You will hit your first RewriteRule and get redirected to the contact form again, but since it's a browser redirect, it will probably just be a GET, so your POST content never makes it to your script.
Try changing the form action to http://accimpress.com/contact-us/ and see what happens.
It looks like CMS Made Simple doesn't support their Form Builder module once you've redirected your URL with Pretty URLs, so my solution for now was using Send This File, like so:
http://accimpress.com/upload/
But thanks for your suggestions Andrew!

Redirect all traffic but "beta" sub-domain to Splash screen (mod_rewrite)

I'd like to redirect all my traffic to my root domain, the root domain being a Splash screen. I'd like to do this ONLY when the %{HTTP_HOST} is not beta.example.(com|es|fr).
So I've tried the following in my .htaccess file, with no luck... (infinite loop... I guess it's not getting the REQUEST_URI condition, but cannot figure out why?? I've tried almost everything)
RewriteCond %{HTTP_HOST} !^beta\.example\.com$
RewriteCond %{HTTP_HOST} !^beta\.example\.es$
RewriteCond %{HTTP_HOST} !^beta\.example\.fr$
RewriteCond %{REQUEST_URI} !^/?$
RewriteRule ^.*$ / [NC,L,R=302]
At that point, I should have all my traffic but "beta" sub-domain redirected to the root domain. So now I'd like to Rewrite "backstage" the root domain with my Splash screen, following in the .htaccess file:
RewriteCond %{HTTP_HOST} !^beta\.example\.com$
RewriteCond %{HTTP_HOST} !^beta\.example\.es$
RewriteCond %{HTTP_HOST} !^beta\.example\.fr$
RewriteRule !\.(js|ico|txt|gif|jpg|png|css)$ splash.phtml [NC,L]
Note: I'm using the Zend Framework, so these rules are following in the .htaccess file:
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
I must say, I'm stuck.
thx in advance
#bsagols
This line from Zend is going to screw you up for sure.
RewriteRule ^.*$ index.php [NC,L]
You need to put your directives above this, if not above all of the Zend stuff. If I'm understanding you correctly, try this:
RewriteCond "%{HTTP_HOST}" "!^beta\.example\.(com|es|fr)$" [NC]
RewriteCond "%{REQUEST_URI}" "!\.(js|ico|txt|gif|jpg|png|css)$" [NC]
RewriteRule ".*" "/splash.phtml" [R=302,L]