Rewrite url pdf file - url-rewriting

i have website and show my pdf file with link domain/assets/slipgaji/2014/4-2014/2004.06.0319.pdf how to change a simple url with rewrite engine .htacces to domain/2004.06.0319.pdf
i tried with everithing rewrite rule on .htaccess and can't shown my file.
here my script eror
RewriteCond %{REQUEST_FILENAME} assets/slipgaji/[0-9]+/[a-z0-9]+.pdf$
RewriteRule ^(.*)$ index.php?/assets/slipgaji/fetch/$1 [L]

Related

codeigniter page not found on live server

codeigniter page not found showing but working fine in local server.
I had uploaded codeigniter file of one basic simple page on live server but there it is showing no page found and same file it is working on local server.
In that I had
mine.php ---- controller
index.php --- view
I loaded in routes default controller - mine in config base url- domain.com removed index.php also
.htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
can I know please why it is showing page not found, might be some routing issue but I had loaded default controller also. Please help out on this
First of all start error logging properly so you can see the actuall error.
Change your file name's first letter capital. This is mendetory as explained here ci3 manual - controllers. It says class name as well as file name must start with capital. ( If your Dev machine is windows then it will not show errors if you don't follow this rule. Because window's file system is case insensitive. But on your server it is linux.so it will show error)
If you still don't get it working then try access the url with index.php in it. Temporaryly disable .htaccess .If you get it working then may be you have problem in . htaccess. Try the following link to properly remove index.php from your url. Expression engine forum .This htaccess worked for me on all different server I have used.
add this in .htaccess file
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond $1 !^(index\.php|images|asset|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

url rewriting issue need to hide .php extension

I want URL rewriting solution.
I have this URL [http://dailyimage.in/photo.php/1480]
and I want to hide .php or [http://dailyimage.in/photo/1480] this type URL
Now I am using this code but it's not working in my .htaccess file
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule !.*\.php$ %{REQUEST_FILENAME}.php [QSA,L]
Try instead of using %{REQUEST_FILENAME}.php using %{REQUEST_URI}.php in your rewrite destination :
RewriteEngine on
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule !.*\.php$ %{REQUEST_URI}.php [QSA,L]

How do I exclude stylesheet and javascript files from my rewrite rules?

I have a rewrite rule currently as shown below:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/([^/]+)$ $2.php?locale=$1 [QSA,L]
RewriteRule ^([^/]+)/([^/]+)/([^/]+) $2.php?page=$3&locale=$1 [QSA,L]
My page URLs are like this:
http://example.com/en/new
or this:
http://example.com/en/new/1
As for the index page it's like this:
http://example.com/en/index
and I wanna get rid of the 'index' word so I added this rule:
RewriteRule ^(.*)$ index\.php/$1 [L]
Which works as expected except for my web assets (css, js files) which are located under: /css and /js folders now has 500 error. So my question is how to I exclude URLs pointing to these files under these 2 directories from being rewritten.
This solved my problem. Either use the suggested answer from here
http://stackoverflow.com/questions/1848500/htaccess-mod-rewrite-how-to-exclude-directory-from-rewrite-rule?rq=1
or simply create a .htaccess file inside the directory where you don't want rewriting to take place and put this in:
RewriteEngine Off

Redirect image url to another page using .htaccess

I want to redirect this url
http://192.168.1.101/project/test/wordpress/wp-content/uploads/2013/06/Sunset.jpg
to this with main url as following.
http://192.168.1.101/project/test/wordpress/redirect.php?file=http://192.168.1.101/project/test/wordpress/wp-content/uploads/2013/06/Sunset.jpg
If url contain extension like .jpg, .png, .jpeg, .bmp, .png then move all it to redirect.php with file name like.
http://192.168.1.101/project/test/wordpress/redirect.php?file=imagefile
My current .htaccess code
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /project/test/wordpress/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /project/test/wordpress/index.php [L]
</IfModule>
# END WordPress
Please Help Me..
Insert this line just after RewriteBase line:
RewriteRule ^wp-content/.+?\.(jpe?g|png|gif|bmp)$ redirect.php?file=http://%{HTTP_HOST}%{REQUEST_URI} [NE,R=302,L,NC]
Once you verify it is working fine, replace R=302 to R=301. Avoid using R=301 (Permanent Redirect) while testing your mod_rewrite rules.

CodeIgniter CSS .htaccess 404 error

I am building an admin section in codeigniter for my site and wanted to have a separate CSS folder for the CSS files for the admin section as they are going differ to those for the main site.
Current my CSS files sit in assets/css
I added and extra folder to that called admin and placed my new CSS files in that ie
assets/css/admin/css/style.css
However when I click the link in source code view to that stylesheet, I get a 404.
My current .htaccess reads as follows:
RewriteEngine On
RewriteCond $1 !^(index\.php|assets|editor|css\/|admin|js|scripts|images|img|media|xml|user_guide|robots\.txt|favicon\.ico)
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
What would I need to do to enable this file.
Note the strange thing is I have 4 CSS files in the folder, two of them whem clicked in the view source ope okay, and 2 of them contain the 404.
use this:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]

Resources