mod-rewrite

htacces to serve cached files

I have a file caching system for a php application. if a file needs cached i save it to a cache dir as flat html mimicking the directory structure of the request_uri how could i check with htaccess if there is a flat file in this cache dir before continuing as normal? currently i check with php, but ideally if there is a cached file, i ...

Adding slashes to the end of directories + more (htaccess)

This is beyond my level and I need some help. In the htaccess make redirect rules for the following... if example.com/1stleveldirectory doesn't end in a slash add one. if example.com/1stleveldirectory/ ends in a slash don't add anything. if example.com/1stleveldirectory/file is like this add .html. if example.com/1stleveldirectory/fil...

How does the .htaccess mod_rewrite for my Site: http://bit.ly/2Ocf3B looks like, to have SEO friendly urls?

I'm trying to optimize my site to make it SEO and user-friendly, I have several problems to set the right mod_rewrite for the urls and need help for this, I'm new to it, so it's way beyong my knowledge for the moment. http://bit.ly/2Ocf3B , the site should look like this: www.domain.me/category/subcategory . thanks ...

How to include a dash(#) in a htaccess rewrite rule?

As you know the dash introduces a comment how can I make this valid? Options +FollowSymlinks RewriteEngine on RewriteRule ^(.+)\.php$ /#$1 [R=301,NC] ...

What is the best way to share common logic between identical template-driven websites?

I've built a white label website in PHP that uses templates. Each white label will have it's own set of templates and possibly a few extra folders. All the white label sites are on the same LAMP server. What I would like to do is keep one centralised copy of the main code on the server and then have every site point to these files. Then...

safe url with .htaccess and moderewrite

hi guy its my first time here and my english sukcs, sorry... i have a problem with my .htaccess, i'm trying to redirect a page with a safe url using this code: RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^noticias/pagina/([0-9]+)/?$ news.php?id=$1 [NC,L] but my swf files called...

Rewrite http to https on some pages only using .htaccess

Hi, I know there is lots of topics regarding my question. I checked them all and tried them out but can't make it work. I need to rewrite http to https on some pages only. After visiting https pages the URL would go back to http. This is what I have so far: # Rewrite Rules for domain.com RewriteEngine On RewriteBase / #Rewrite www ...

Running PHP without extension without using mod_rewrite?

Using Apache 2.2 and PHP 5, what's the best way to run PHP without the .php extension. For example, I have a script called app.php and I like to invoke it as http://example.com/app Please notice that I still want keep the .php extension to the file and I don't have mod_rewrite. Don't want use index.php either because it requires too ma...

how to change the way of GET variables work in php

I dont like something like this: example.com/?id=2222. How to change it into example.com/2222? ...

mod_rewrite works for '/test', but not for '/'.

The following code inside an .htaccess file is behaving incorrectly.. RewriteEngine on RewriteBase / RewriteCond %{HTTP_HOST} ^(domain\.com)$ [NC] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^/(.*)$ /test/$1 [L,QSA] The above will correctly send requests to 'domain.com/uri-here' to the '/test/'...

mod-rewrite question: /test/method is rewritten to test.svg/method

I noticed an odd (to me) mod_rewrite thing happening. Fixing it is not important to me so much as figuring out what's going on. Basically, I have an svg file called test.svg in my document root, as well as an index.php. My expectation, based on my .htaccess file is that visiting http://localhost/test.svg would get me the .svg file (and ...

ASP.NET + URL Rewriting: How to handle themes, css, js, etc resources?

I've written URL using Helicon ISAPI Rewrite v3 for following: www.foo.com/tags/tag1 --> www.foo.com/Pages/Articles/ArticleListing.aspx?tags=tag1 But the .css, .js i've refered are being accessed by browser as www.foo.com/tags/tag1/style.css www.foo.com/tags/tag1/myjs.js but these files are located as www.foo.com/css/style.css www...

to write htaccess code for friendly url

I need a help, does anyone can tell me how to change a url "http://www.domain.com/search.php?key=+Ebooks&amp;type=title&amp;Submit=Search" to "http://www.domain.com/keyword- keyword- keyword.html". i have written following htaccess code but its not working. <IfModule mod_rewrite.c> RewriteEngine on RewriteRule search-(.*)-(.*)-(...

How to always remove WWW from a url with mod_rewrite?

I'm using the following to try and remove WWW from the url: RewriteCond %{HTTP_HOST} ^example.com$ [NC] RewriteRule (.*) http://example.com$1 [R=301] But for some reason it doesn't work. Any suggestions? ...

Security: Deny access to .hg/* via mod_rewrite

My website is a mercurial repository with multiple subrepositories. I need to make sure I'm denying access to all files in every .hg directory on the server. For example, I have http://example.com/.hg/ and http://example.com/subrepo1/.hg/ I've added the following to .htaccess: <Files ~ "^\.(hg|ht)"> Order allow,deny Deny from ...

Rewrite rule for the following

I have news items on my website that get rewritten using the following rule: RewriteRule ^news/([^/]*)/([^/]*)$ /local/?page=home&news_id=$1&newsTitle=$2 [L] Now one of the news item’s title is: achieves_100%_A*_to_C_in_GCSE But the page doesn't get displayed and I get a 400 error. I think that the problem is with the % and the * in...

drupal reinstalled locally, URLs such as "admin" get page not found

I've just downloaded my drupal site. I can view the home page and the content seems to be read from the db. However i can't get to http://localhost:81/admin or http://localhost:81/aboutus I have enabled "mod_rewrite" i can view content such as "?q=node/266" I've setup virtual host ServerName localhost DocumentRoot "C:/wamp/www/m...

mod_rewrite rule: if URL contains a certain string

My client keeps editing the structure of the navigation in the website, which is leading to some mod_rewrite issues. How could i make this rule: RewriteRule ^studios/about-studios/artist-noticeboard noticeboard2.php?section=studios&subSection=studio-artists [L] to work if the url contains "noticeboard"? Like this: RewriteRule ^IF CON...

How to rewrite and set headers at the same time in Apache

I have a directory of images that alternately be viewed directly in the browser, and other times downloaded. So, say I have a file /gallery/gal_4254.jpg. I want to make /download/gal_4254.jpg trigger a download of the image rather than view it. /download is empty, all the images are in /gallery. I can map requests to the download d...

Using Timthumb to Resize Images from CKEditor

I am using CKEditor to do basic text and image input into my website. I have noticed that it is quite sporadic in it's method of generating HTML for images when you add them. (Sometimes it might use height and width tags, other times it might use CSS). I use Timthumb for on the fly image resizing on a number of other websites and find i...