.htaccess

htaccess - moving blog to subdomain

i have a blog, and im moving it to a subdomain. since the URL sintaxis won't be the same, i just want to redirect all url requests that are inside /posts/ to the new subdomain: from domain.com/posts/xxxxx to blog.domain.com this is what i have so far, but it still has to filter only the requests that are inside /posts/ RewriteCond ...

setting cache headers in .htaccess file

I put the following code in my .htaccess file. But when I run my application, I get server error. I put the code to improve my site's performance. RewriteEngine On RewriteBase /domainname/site/ RewriteCond %{REQUEST_URI} ^system.* RewriteRule ^(.*)$ /index.php/$1 [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-...

Securing one particular file on the server; .htaccess good way of doing it?

I have a classifieds website. I as an administrator need to be able to remove classifieds as I wish... So I have created a very simple remove function which only requires the name of the classified. I plan on placing it on the server ONLY when I need to remove classifieds, so it wont be there unless I upload it and plan on using it. Th...

How to handle meta elements not validating in HTML5?

Hi guys! In HTML5, some meta elements do not validate (yet?) like: <meta http-equiv="x-ua-compatible" content="ie=emulateie7;chrome=1"> <meta http-equiv="imagetoolbar" content="no"> Are Conditional Comments an appropriate solution here resp. will meta elements still work as expected? <!--[if IE]><meta http-equiv="x-ua-compatible" con...

Hard redirect file.php to /file (when /file is already being transparently redirected to /file.php)

Am already transparently redirecting requests for /file to /file.php -- accessing /file shows /file.php. My .htaccess: RewriteEngine on RewriteBase / RewriteRule ^([a-zA-Z]+)/?$ $1.php [L] Would now like to do a hard redirect for /file.php to /file -- if I hit up /file.php, URL in the address bar must show /file. Tried the following b...

Htaccess subdomain rules

Hi all, I use htaccess with a set of rules to control the different pages of my website. If a user visits my main site (domain.com), without using www it 301 redirects to www.domain.com (for SEO purposes) I use wildcard subdomains, so if a user visits subdomain.domain.com, they will view a specific PHP file that decides to content for...

.htaccess RewriteRule non-www to www without explicity specifying domain

I'm trying to make a general rewrite rule to redirect all domain.com requests to www.domain.com. RewriteCond %{HTTP_HOST} ^([0-9a-z-]+)\.([0-9a-z-]+])$ [NC] RewriteRule ^(.*)$ http://www.{HTTP_HOST}/$1 [R=301,L] The problem is that this rewrite rule doesn't match anything. How can I change it? Thanks ...

Dynamic subdomains + defined subdomains via htaccess

I hate asking questions about mod_rewrite, but I can't seem to get these rules working properly. I had it setup and figured out once before, but a few years have passed and now it's just not playing nice and my mod_rewrite knowledge is back to uhhhh...... Essentially what I want to do is force www on the main domain, example.com. (or f...

Redirect to a sub folder using .htaccess

I moved a website over to a sub folder and I added a htaccess file to the root of the site. For some reason it is not redirecting to the subfolder. below is my code Options +FollowSymLinks # # mod_rewrite in use RewriteEngine on RewriteBase /public_html/corp/ i also tried Options +FollowSymLinks # # mod_rewrite in use Rewrit...

How to remove subfolder from url

I moved my site to a subfolder called /corp/. So to get to the site you type in mywebsite.com/corp/index.php I would like to remove the /corp/ so it looks like mywebsite.com/index.php Thanks for all the help! ...

How do I tell search engines not to index content via secondary domain names?

I have a website at a.com (for example). I also have a couple of other domain names which I am not using for anything: b.com and c.com. They currently forward to a.com. I have noticed that Google is indexing content from my site using b.com/stuff and c.com/stuff, not just a.com/stuff. What is the proper way to tell Google to only index c...

htaccess redirect - stricter matching on 301?

The following htaccess based redirection rule works fine: Redirect 301 /content/category/2/24/30/ /new/c/url/ The problem is it works too well. If a user goes to /content/category/2/24/30/50/50/ it will redirect to: /new/c/url/50/50/ How can I get it to do a strict match? Either redirecting both examples to simply: /new/c/url/...

.htaccess Issues, Virtual Subdomains & Codeigniter

Hello guys, basically my problem is this. I have set up a system that accepts wildcard subdomains, and rewrites them to a single CodeIgniter installation. There is a controller called dispatcher that takes the arguments that it requires, as well as being passed the subdomain being used in the URL. My problem is this: I need to create Re...

URL Rewriting on Localhost? Apache PHP

Hi, I am using Apache mod_rewrite on Xampp on my local machine but the code doesnt seem to work. Please look at the code below and assist me. I'm a beginner with this. RewriteEngine on RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^m3/([a-zA-Z0-9-]+)$/?profile=com...

limit visits to site

i need to limit visits to my site from some regions. how can i don't allow to visit my site from some country?(from Armenia for example) (what is the way i must go? .htaccess? or maybe only by ip addresses?) ...

replace host in htaccess

Hello! I am creating a website which is located in /shop/ on my webserver. It has a seperate domain. Now, I want to change every request that comes in. http://techinf.de/shop/ shall become http://holzwerkstatt-osel.de/ and http://www.techinf.de/shop/ shall become http://www.holzwerkstatt-osel.de/ the actual request, like product.php?...

.htaccess redirect prob.......

I created a site in 2 languages english (en) and arabic (ar). Whenever a visitor comes to mysite.com (index) he chooses a language and he will be either directed to ar.mysite.com or en.mysite.com ...the problem and you already know it, don't you? is that he is redirected to mysite.com/en/index.php instead of en.mysite.... and the same st...

Optimizing the website with .htaccess

I've tried to optimize my website using YSlow for directions. However, even though I have added the DEFLATE code at .htaccess to gzip the files, YSlow still doesn't show the files as gzipped. I tried testing my website using this: http://www.gidnetwork.com/tools/gzip-test.php and it shows that my webpages are not gzipped or compressed. H...

.htaccess: sanitize a query string

So I have some particular variables that mess up the content management system I'm using. While I debug the code, I'd like to redirect requests with these particular variables back to the index page, but without any query string. Here's my rule: RewriteCond %{QUERY_STRING} option\=com\_aicontactsafe\&sTask\=captcha RewriteRule (.*) ...

Redirect "mydomain.com/user" to "mydomain.com/name.php?id=user"

I think I can use the .htaccess file for this, but I've looked it up and not found anything useful. What I want to do is have my site redirect to a php page when a user types their username in the URL like: example.com/username And have it be the same as a PHP page like: example.com/name.php?id=username I'd like it to display as ex...