It has been a while i've played arround with the engine rewrite functions in the htaccess file.
But due some merged projects and some pretty damn ugly looking url's that would be tomuch work for a simple application to work i've decided to use enginerewrite to make things a bit more pretty.
However, like always there is a catch that i've been struggling with for the past 2 days, the image folder.
To give an example, url's are changing to domain.com/firstpage/firstparam/secondparam/ultimateparam/
the issue here is the images on the page, that are broken because there is no image folder under the uri domain.com/firstpage/firstparam/secondparam/ultimateparam/images/
so my question here is, how can i ignore everything infront of /images/ and make it link to the actual images folder ?
Thanks in advance !
One awnser profided by Amit Verma.
putting a / infront of the path to the image, ex;
<img src="path/to/image.png">
to
<img src="/path/to/image.png">
seems based on the (sub)domain.
Not exactly what the question was, but it solved my issue regardless, thanks!
Related
I'm trying to redirect a file using a fake folder, but I can not get it to work properly. I've been searching and trying different things but none of them worked out for me.
How my current URL looks like:
/new-weblog.php
How I want the URL to look like:
/weblogs/new-weblog.php
I do not want to redirect ALL urls to have the fake /weblogs/ folder. Only just for that one specific file.
Thank you in advance.
This doesn't qualify as an answer, however, this is a good tutorial that will give you the desired solution you're looking for and teach you about htaccess commands while you're at it.
Here's the link: https://www.addedbytes.com/articles/for-beginners/url-rewriting-for-beginners/
I've been searching around and tried many different ideas to fix the state of a URL for my client, but have had no joy.
The URL currently looks like this:
website.com/folder1/folder2/folder3/page.php
My client wants this to be showing much like the other links on the website as so:
website.com/page
I'm fine with removing the .php that's simple enough and is already written into my .htaccess file. It's just removing the 3 directories from the URL is what I cannot work out.
Before anyone asks about moving the file to a higher directory, I'm afraid this cannot be done as everything needs to be down in this 3rd directory for this page.
I believe my latest attempt is about the closest I've got to solving this, if anyone could point out my mistakes and a solution it would be much appreciated:
RewriteRule ^/folder1/folder2/folder3/(.*)$ /page$1 [L,R=301]
EDIT:
After researching more today, I think I may have confused people with this question. I think what I should have said is that I need to mask the URL, hiding the 3 directories, and showing just the domain and the page itself.
I still seem to be hitting a wall with masking too. Any advice?
After a whole weekend (and quite a bit of the week between working) I finally managed to succeed with what I wanted.
The site now displays as required:
website.com/page
Which has been redirected and masked from:
website.com/folder1/folder2/folder3/page.php
The piece of code required in the .htaccess is as follows:
RewriteRule ^page$ /folder1/folder2/folder3/page.php
Looks like I was being stupid before and had the syntax backwards, but all is well now and I'm allowed to sleep :)
Hope this helps anyone else in future with this sort of problem!
I have a quite complicated hotlinking problem. Since I my understanding of .htaccess is kinda terrible, I'll pseudo-code it:
1:Every embedded Image call should redirect to a "do not hotlink" image
2:Every direct hit to an image with let's say: domain.com/folder/IMAGENAME.jpg should redirect to my page containing the image e.g. domain.com/IMAGENAME.html
3:search engines should be unaffacted or at least still be able to crawl them for image searches
Thanks for the help :)
I have a networking site that has member data organised into subfolders. To access the data, a user would need to go to something like:-
www.domain.com/members/so/me/on/esfolder
My question is, can I use a function in the .htaccess file to allow users to visit the same page by just typing:-
www.domain.com/members/someonesfolder
I have read up on the Rewrite syntax but struggling to understand how to do this. It is simply a case of removing the forward slashes after a particular point.
Any ideas? Thanks in advance.
I've figured it out myself after a non-stop mess around lasting several hours... For those who might want to know, here is the code I used...
RewriteRule ^members/([A-Za-z0-9]{1,2})([A-Za-z0-9]{1,2})([A-Za-z0-9]{1,}) members/$1/$2/$3/ [L]
In the above, there is just three sub-folder drill downs (which is what I have decided to do rather than the four in my original question).
Hope this helps someone else!
I would like to find a way for users to be able to type their username after my domain name to access their public profile page.
For example, if you type youtube.com/username it shows that user's channel page. The resulting page is the same as youtube.com/user/username.
So with my website, I have mydomain.example/users/profile.php?name=username
It's a bit more complicated, with PHP and variables and subdirectories and everything... I would like that same page to display when I type mydomain.example/username
I really have no idea where to start with this, but I suspect it would be something in the .htaccess file, which I do have access to.
Thanks for any help!
edit: sorry this is a few days old, I've been having some other troubles and I haven't been able to test it until now. Anyway, it isn't working...
Just to recap, I want mydomain.example/username
to filter to
mydomain.example/users/profile.php?name=username
Thanks..
edit2: I found this also on stackoverflow... link text i tried tweaking that, and what was mentioned here a few days ago... but it still won't work. Any ideas?
I also keep finding pages that recommend the strategy this guy used: link text but it looks like that would cause more problems than it's worth.
Any ideas?
RewriteEngine on
RewriteRule ^user/(.*)$ profile.php?name=$1 [NC,B,QSA]