htaccess won't redirect properly - apache

Currently i'm working on a backend website admin but i have some trouble with redirecting. The issue is this when someone wants to edit a specific job function he needs to be redirected to for example: jobs/edit/Webdeveloper and in the PHP script it will send in an action to go to the edit page but when i redirecting it, it stays on the same page and does a simply refresh.
This is what i have as an link tag:
<a href='".$adminurl."/jobs/edit/".$list["function"]."'>Change</a>
And it works out like this domain.com/admin/jobs/edit/Webdeveloper
This is what i have in my .htaccess
RewriteRule ^jobs/change/(.*) jobs.php?&action=change&job=$1
What am i doing wrong here?

Related

Apache redirect if there are two directories in URL

I have a site where there are user accounts and pages for the public.
I would like to be able to access a users account with a URL like
http://mySite/theUserName
and access the back pages with
http://mysite/page/pageName
I have a RewriteRule currently that looks like this which works for redirecting the page.
RewriteRule ^page/(.*)/? /application/pages/getPage.php?page=$1 [NC,L]
How ever if you try and access a user account it still runs the rule as the rule doesn't know a page name was not given.
So how do I run the rule only if both "page" and "pageName" are provided and ignore it otherwise.
I guess another way that would not be as clean but would work is only run the rule if the first directory is "page"
Thanks for any help you can provide.

htaccess preventing "<script>" in url and hex script

I am working with htaccess and I want to secure my website from attacks/injections of scripts in the url and I want to deny access to my site and record their ip address and deny them if they run their script it will stop it and close their browser .is it possible because from experience I have been using htaccess to hide the extension name of the pages that I have made help with this one would really be great.
and also this code which redirects
Redirect 301 / http://www.newdomain.com
Sure, there's a way to use a .htaccess file to detect whether <script> is in the URL and redirect them if so, but hopefully that's not your only line of defense. If you start blocking <script>, then maybe they'll start using <script > or <img onload=""> or, or, or… oh dear. The point is that filtering attacks is insufficient; instead, let them submit whatever data they want (even if it appears malicious), but prevent it from doing any harm by escaping appropriately.
That said, a RewriteRule like this might do it:
RewriteRule <script> http://www.example.com/ [L,R]
To log it, you could have not .htaccess do the redirect but rather route the request to some server-side script which logged it and then redirected. Alternatively you could just filter the access log yourself.

Redirecting from example.com to www.example.com

My site uses AJAX, and it seems like I have to include the full path when I use it to access a function. This is fine, as I can code it in. The problem is, I have hardcoded http://www.example.com... but if a user has gone to http://example.com (without the www) this gives an access problem and the AJAX won't execute.
I think the easiest way to resolve this would be to make sure that if a user goes to mysite.com, they are redirected to www.example.com.
I can find solutions online, but they all involve the htaccess file, which my server doesn't support - I have to use rewrite.script instead.
How can I do this using rewrite.script, or is there an alternative way to approach this?
Thanks for the suggestions - I was directed to this: http://seo-website-designer.com/Zeus-Server-301-Redirect-Generator which created the rewrite.script file I needed.
In .htaccess found in your root document:
Redirect http://example.com/ http://www.example.com/
If there is no support for .htaccess on your server, you may have to include meta tag redirect on the head of your page. or using javascript to check the URL source then redirect it.

Use .htaccess To Redirect Page Without Changing URL With 'mod_rewrite'

I have a script on my page that checks the url for the word signing. If the word exists, it shows the signin form in a dropdown on page load. I'd like to avoid creating extra files on the server, so I was wondering how I could do this:
When the user is at either of these urls:
http://abramobile.com/signin
http://abramobile.com/sign-in
Then direct the page back to the homepage, but leave 'signin' or 'sign-in' in the URL so that the script on my page detects that it's in the URL.
What would the mod_rewrite be to put in my .htaccess file? Thanks!
This should do it. This matches against the URI being exactly /signin or /sign-in and internally rewrite the URI to / so that that gets served.
RewriteRule ^sign-?in$ / [L]

How to change page type without losing past SEO value

As time goes on we are sometimes required to change a page that is ranked well to a new page name. For instance, GreatInfo.asp to be replaced by the same content but called GreatInfo.php
It's basically a 301 redirect but on the page level. I'm running Windows Server (IIS7) and can do full site 301 redirects but not clear on the same goal for a single page.
I researched this page but still it is not clear:
http://www.seomoz.org/learn-seo/redirection
This page concludes in saying to simply paste code on your page to achieve the individual page 301 redirect:
http://www.bruceclay.com/blog/2007/03/how-to-properly-implement-a-301-redirect/
but yet no reference is given to such code..
So I would have to say my question is what code is used at a page level to do a single page 301 redirect?
I believe I found the answer:
301 redirects in PHP
In some cases, you can’t do it with .htaccess so you’re stuck doing it at the page level. If you need to do a 301 redirect in PHP, here’s how:
<?php
header(“HTTP/1.1 301 Moved Permanently”);
header(“Location: http://www.example.com/”);
?>
Note: you’ll need to make sure you don’t echo out any HTML or text before executing these functions.
301 redirects in ASP
If you’re using ASP, it looks like this:
<%
Response.Status = "301 Moved Permanently"
Response.AddHeader "Location", "http://www.example.com/"
Response.End
%>
Now whether this retains any positive SEO ranking from the page setting the 301 redirect, I do not know... Also I've not found the same page level methods for a static html page redirect. But at least for classic asp and php the methods above will work well.