I need to make a change to my Apache web server to redirect requests for the home page from iPhone browsers to a different page. I've edited the /etc/httpd/conf/httpd.conf file and added the following:
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} .*iPhone.*
RewriteRule ^/$ /iphone/index.html [L]
After making the change, I restarted httpd, but the redirect doesn't work.
Am I missing something? Do the edits need to be made to a specific location in the httpd.conf file?
Other info: Server is vps hosted by Lunarpages running CentOS 5.5 and Apache 2.2.3.
For me, I use like below
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} .*iPhone.*
RewriteRule ^[\./]$ <MyDomain>/iphone/index.html [L]
Related
I installed cs cart on new server and also enabled the API user access. But the api is giving back 404 not found error. Not sure what is needed in here.
Can anyone please help!!
please try yoursite.com/api.php?_d=products (e.g. in browser)
if it works, make sure that .htaccess root file (for apache servers) has lines:
RewriteCond %{REQUEST_URI} ^api/(.*)$ [or]
RewriteCond %{REQUEST_URI} .*/api/(.*)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .*api/(.*)$ api.php?_d=$1 [L,QSA]
it might mean issue with mod_rewrite which is not configured or configured incorrectly on the server
p.s. if the server is on nginx, analogue configuration is needed
Enable API for an administrator user
Folow documentation
https://docs.cs-cart.com/4.9.x/developer_guide/api/index.html
I'm running Apache 2.4 and using mod_rewrite to achieve the following - I need to proxy several different internal sites so that they appear to have been hosted on the same server. As an example, the way I'm looking to do this is to have URL's of the form http://myserver/osnews
which will proxy content from www.osnews.com and http://myserver/slashdot which will proxy content from www.slashdot.org. I have the following rewrite-rule defined in my apache conf file:
RewriteCond %{REQUEST_URI} ^/osnews(/?.*) [NC]
RewriteRule ^/osnews(.*) http://www.osnews.com$1 [P]
RewriteCond %{REQUEST_URI} ^/slshdot(/?.*) [NC]
RewriteRule ^/osnews(.*) http://www.slashdot.org$1 [P]
The problem is that this breaks all the stylesheets and images from the proxied site. I think it's because the rewritten URL's are of the form http://myserver/story/28554/Russia_unveils_homegrown_PC_microprocessor_chips instead of http://myserver/osnews/story/28554/Russia_unveils_homegrown_PC_microprocessor_chips
On the contrary, if I try something like this, it works just fine (I don't have the site as part of the original url so http://myserver will just proxy to http://www.osnews.com):
RewriteCond %{HTTP_HOST} ^myserver$ [NC]
RewriteRule ^ http://www.osnews.com%{REQUEST_URI} [P]
So, what I need direction on is how to preserve the URL http://mysite/osnews/some-resource after the proxying returns from http://osnews.com/some-resource
Thanks!
So, I have got this working using mod_proxy instead of mod_rewrite. The configuration I used (within the VirtualHost context) is:
ProxyPass /osnews.com/ http://www.osnews.com/
ProxyHTMLURLMap http://www.osnews.com /osnews.com
#LogLevel debug proxy_html:trace5
<Location /osnews.com/>
ProxyPassReverse /osnews.com/
ProxyHTMLEnable On
ProxyHTMLExtended On
ProxyHTMLURLMap ^/ /osnews.com/ R
ProxyHTMLURLMap ^/css/(.*) /osnews.com/css/$1 Rc
ProxyHTMLURLMap ^/images/(.*) /osnews.com/images/$1 Rc
RequestHeader unset Accept-Encoding
</Location>
One thing to note is that if you're using apache2 on Ubuntu (Lubuntu 15.04 in my case), the config file for mod proxy_html is not provided by default. You need to create it and then enable it using a2enmod proxy_html. This article summarizes it well: http://ckdake.com/content/2008/reverse-proxying-with-apache-and-modproxyhtml.html.
There are still some issues I see where the ProxyHTMLExtended output-filter is not mapping URLS correctly. But I expect to get those ironed out eventually.
I have a website running with a content management system running in the root of my website. I have installed the latest version of Opencart in a sub-directory called "shop" - so www.domain.com/shop/
Everything works fine and I can use Opencart as expected.
I need to install VQmod so have uploaded the files to the root of the shop folder, I have set the correct permissions trying 755 and 777 but with no luck.
Every time I go to www.domain.com/shop/vqmod/install I get a 403 error.
Same with www.domain.com/shop/vqmod/
Forbidden
You don't have permission to access /shop/vqmod/install on this server.
Apache Server at domain.com Port 80
My .hta file is pretty much standard apart from taking out the index.php? out of the urls and a rewrite rule to say change the home link.
RewriteBase /shop/
RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [L]
RewriteRule ^download/(.*) /index.php?route=error/not_found [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]
RewriteCond %{QUERY_STRING} ^route=common/home$
RewriteCond %{REQUEST_METHOD} !^POST$
RewriteRule ^index\.php$ http://%{HTTP_HOST}? [R=301,L]
I am running on an apache server mentioned in error and on plesk control panel. I am stuck!
Also I have a .hta file in my very root where the cms files are how do I ensure that does not conflict the with opencart website.
found it at last....
.htaccess in of vqmod is set to Deny from all. change it to allow and it should work fine!
Did you also change the file permissions for your www.domain.com/shop/index.php and www.domain.com/shop/admin/index.php files during vqmod installation?
This is vital as changes are made to these files during the auto-installation process.
I've just setup an AMP server on OSX 10.9 and have a bizzare problem which is not present on my live hosting server or my old WAMP server.
I want to redirect any URL that doesn't directly map to a file on the server to index.php. I'm using the following .htaccess code
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# prevent loop
RewriteCond %{REQUEST_URI} !index\.php
RewriteRule ^(.*)$ /index.php?/$1 [L]
when I try http://example.com/example there is no problem, but when I introduce another slash, for example, http://example.com/example/
I get the a 404 error The requested URL /example.html/ was not found on this server.
Server version: Apache/2.2.26 (Unix)
Looks like your problem is related to enabling of MultiViews here. Turn it off by using this line on top of your .htaccess:
Options -MultiViews
Option MultiViews is used by Apache's content negotiation module that runs before mod_rewrite and and makes Apache server match extensions of files. So /file can be in URL but it will serve /file.php.
can someone tell me how to convert apache iis7 mod_rewrite .htaccess file to the equivalent web.config in MS Url Rewriter?
Here is the .htaccess file I have:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /index.php?url=$1 [QSA,L]
</IfModule>
These look like WordPress rules. WordPress understands and knows how to modify the IIS 7 web.config file automatically. If you use the platform installer to install WordPress you don't have to worry about any of this:
http://www.microsoft.com/web/downloads/platform.aspx
There is also an Apache Rewriter config import into Microsoft URL Rewriter. And if you truly like Apache style syntax there is the URL Rewriter project provided by Managed Fusion, which supports Apache rules on IIS 6 and 7:
http://urlrewriter.codeplex.com