I have a problem with my queries doesnt work the image of the source, so i have root/travel-page.php in the root folder and on the query i want put a image from root/travel/imagini/picture.jpg .. i putted all the html link http://exemple.com/travel/imagini/picture.jpg , but doesnt work
the page.php i redirectionat using htacces in travel/queryLink.php
So my question is if i can do something to make those image to appear if is 2 level of folder diference between the page and the image
if i try to call the image from root/images/picture.jpg - is work.. because is only a level between thoose.
RewriteRule ^travel/([0-9a-zA-Z_-]+) ./page.php?pid=$1 [NC,L]
I FIXED the problem, maybe someone will have the same problem with the image what not show after the RewriteRule
i needed to add RewriteCond %{REQUEST_FILENAME} !-f
so the right code is this...dont forget to request the filename how i did it.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^travel/([0-9a-zA-Z_-]+) ./page.php?pid=$1 [NC,L]
Related
I have a dynamic URL like
<domainname>/sub/cl/<phpfile.php>?c=123
phpfile.php can be any php file which comes in run time
/sub/cl/ is a folder path.
i have use this code in .htaccess:
RewriteRule ^sub/cl/new-file/([0-9]+)/?$ sub/cl/newfile.php?c=$1 [NC,L]
this is correctly redirecting to the newfile.php when i hit /sub/cl/new-file/321/ but sub/cl/ get appended before all css and js which are in root and also c=321 get lost
Please help me what m doing wrong.
Thanks in advance
if your problem is only query string insert [QSA] flag to to the rule. JS/CSS/IMG files are losing because the rewrite works for every request. Over come this issue by adding RewriteCond
RewriteCond %{REQUEST_FILENAME} !-f #Files
RewriteCond %{REQUEST_FILENAME} !-d #Directories
further reading
Apache Mod_rewrite
I researched for removing page extensions (Ex: /page.php to just /page) and I found this article: http://alexcican.com/post/how-to-remove-php-html-htm-extensions-with-htaccess/
So, I inputed this code into my .htaccess file. It really worked, but when I paste/type my index link at Facebook status with no trailing slash at the end, the Open Graph kinda bugs. There's no thumbnail, no right title and description.
Check it: http://www.aftercolors.com.br
Would the solution be remove the code from .htaccess and create subfolders with index files to have the pages without extension?
That's the code of my .htaccess:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
You can try this one for just single link:
RewriteRule ^page page.php [L]
If you want just to redirect that one simple file. It's better to use id's to get bigger spectrum.
My website is a custom made PHP website. I recently made it SEO friendly by copying the .htaccess file from wordpress and modify it a little. The problem is that some pages are realoaded twice especialy pages that have more than 1 backslash like download/something/ . I have noticed this when tracking pageviews one pageviews is counted as twice and i've done a lot of research regarding this and the pageviews are working good it's a very simple function that inserts a new row each time you view a page.
Things to keep in mind:
My website is inside some folders 'https://localhost/simbyone/sim/index.php'.
I don't want to use any GET variables i will have my variables from the URL string
I want .htaccess to look for existing directories located inside 'https://localhost/simbyone/sim/' and if it doesn't find any open index.php with all the strings attached something like 'localhost/simbyone/sim/blabla/' but inside index.php
everything works exactly as i said above the only thing that doesn't do right is that it double loads some pages
this is my .htaccess file:
RewriteEngine On
RewriteBase /simbyone/sim/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /simbyone/sim/index.php [L]
Thanks in advance to anyone that will help me.
Place the .htaccess inside your base folder (in your case, simbyone/sim).
Just put this in the file:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php
This will rewrite and request that is not an existing file or folder to the index.php file.
There you can use $_SERVER['REQUEST_URI'] to evalute the request (keep in mind that the prefix "/simbyone/sim/" will be present there.
I have a small php script which generates images (GD) for forum signatures. To call them there is an url like : http://www.example.net/img/imgtype_NN.png
Where :
- imgtype is the type of the signature I want
- NN is the ID of the image
When I call this url I want to test if the image already exists in the directory (i.e. if it already has been generated) and in this case I want to show it.
Otherwise I want my script to generate it and then show it.
Here is my actual .htaccess :
RewriteCond %{REQUEST_URI} img/(.*)_(.*).png$
RewriteCond %{DOCUMENT_ROOT}/signatures/img/%1_%2.png -f
RewriteRule img/(.*)_(.*).png$ /signatures/img/$1_$2.png [L]
RewriteRule img/(.*)_(.*).png /signatures/signatures.php?signature=$1&id_pop=$2 [L]
Images are stored in example.com/signatures/img/ and the php script is located in example.com/signatures/signatures.php
After hours of tries I don't have exactly what I need and I give up now, I need some help.
Thanks guys !
Well, your code is not the best so maybe your problem is due to some syntax error.
Anyway, you can try this version (put this code in your root htaccess)
RewriteEngine On
RewriteCond %{DOCUMENT_ROOT}/signatures/img/$1_$2\.png -f
RewriteRule ^img/(.+)_(.+)\.png$ /signatures/img/$1_$2.png [L]
RewriteRule ^img/(.+)_(.+)\.png$ /signatures/signatures.php?signature=$1&id_pop=$2 [L]
Make sure you've enabled mod_rewrite and allowed htaccess in Apache configuration
I'm trying to display images that I upload to my FTP but I don't know what I'm doing wrong.
First of all, I'm saving "uploads/images/".$image['file_name'] in my DB to know the relative URL of the file.
Later, in the target view, I declared the helper('url') and helper('html') to use without any problem the next functions:
img()
base_url()
Having all this done, I call the image as img(base_url($object['image_url'])) where object['img_url'] is called from my DB with the correct structure.
I tried to use the <img> tag too, but the src doesn't loads correctly.
The url that I'm getting from the DB is the correct one, but if I load it at the browser, it appears a 404 error because there is no "uploads" class with "images" method. My uploads folder was created at root level of the project.
What I'm doing wrong? I had to change something in the configuration of the project?
CodeIgniter routes all requests to index.php and looks for a controller. Try adding this to .htaccess
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
Do you have .htaccess. Example:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|js|fonts|products_images|shops_images|uploads|assets|robots\.txt|migration)
RewriteRule ^(.*)$ /dobrioferti/index.php/$1 [L]